package com.hc.serviceimpl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hc.entity.QcEquipment;
import com.hc.mapper.QcEquipmentMapper;
import com.hc.model.QcEquipmentRecordModel;
import com.hc.model.QcRecordStatusModel;
import com.hc.model.QualityControlReportList;
import com.hc.model.WorkbenchModel;
import com.hc.service.QcEquipmentRecordExcelService;
import com.hc.service.QcEquipmentRecordService;
import com.hc.util.ExcelUtils;
import com.hc.util.QcEqRdExcelUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @ClassName QcEquipmentRecordExcelServiceImpl
 * @Description TODO巡检记录excel导出实现类
 * @Author WangZi
 * @Date 2019/12/16 15:51
 * @Version 1.0
 **/
@Service
public class QcEquipmentRecordExcelServiceImpl implements QcEquipmentRecordExcelService {

    @Autowired
    private QcEquipmentRecordService qcEquipmentRecordService;

    @Autowired
    private QcEquipmentMapper qcEquipmentMapper;

    /**
     * 通过状态码转换对应的状态名
     *
     * @param status
     * @return
     */
    private String changeStatus2(String status) {
        String str = null;
        if (StringUtils.equals("1", status)) {
            str = "正常";
        } else if (StringUtils.equals("2", status)) {
            str = "异常";
        }
        return str;
    }

    /**
     * 通过状态码转换对应的状态名
     *
     * @param status
     * @return
     */
    private String changeStatus3(String status) {
        String str = null;
        if (StringUtils.equals("1", status)) {
            str = "是";
        } else if (StringUtils.equals("2", status)) {
            str = "否";
        }
        return str;
    }

    /**
     * 通过状态码转换对应的状态名
     *
     * @param status
     * @return
     */
    private String changeStatus4(String status) {
        String str = null;
        if (StringUtils.equals("1", status)) {
            str = "高";
        } else if (StringUtils.equals("2", status)) {
            str = "中";
        } else if (StringUtils.equals("3", status)) {
            str = "低";
        }
        return str;
    }

    /**
     * 根据运行状态id生成对应的运行状态值
     *
     * @param runningStatus
     * @return
     */
    private String changeStatus(String runningStatus) {
        String str = null;
        if (StringUtils.equals("1", runningStatus)) {
            str = "正常";
        } else if (StringUtils.equals("2", runningStatus)) {
            str = "异常";
        } else if (StringUtils.equals("3", runningStatus)) {
            str = "温度异常";
        } else if (StringUtils.equals("4", runningStatus)) {
            str = "气体异常";
        } else if (StringUtils.equals("5", runningStatus)) {
            str = "风机异常";
        } else if (StringUtils.equals("6", runningStatus)) {
            str = "光源异常";
        } else if (StringUtils.equals("7", runningStatus)) {
            str = "其他异常";
        } else if (StringUtils.equals("8", runningStatus)) {
            str = "湿度异常";
        } else if (StringUtils.equals("9", runningStatus)) {
            str = "停用";
        } else if (StringUtils.equals("10", runningStatus)) {
            str = "故障停机";
        }
        return str;
    }

    /**
     * 根据工作站运行状态id生成对应的运行状态值
     *
     * @param runningStatus
     * @return
     */
    private String changeStatusByGZZ(String runningStatus){
        String str = null;
        if (StringUtils.equals("1", runningStatus)) {
            str = "正常+清洁";
        } else if (StringUtils.equals("2", runningStatus)) {
            str = "异常";
        } else if (StringUtils.equals("3", runningStatus)) {
            str = "温度异常";
        } else if (StringUtils.equals("4", runningStatus)) {
            str = "气体异常";
        } else if (StringUtils.equals("5", runningStatus)) {
            str = "风机异常";
        } else if (StringUtils.equals("6", runningStatus)) {
            str = "光源异常";
        } else if (StringUtils.equals("7", runningStatus)) {
            str = "其他异常";
        } else if (StringUtils.equals("8", runningStatus)) {
            str = "湿度异常";
        } else if (StringUtils.equals("9", runningStatus)) {
            str = "停用";
        } else if (StringUtils.equals("10", runningStatus)) {
            str = "故障停机";
        }
        return str;
    }

    /**
     * 工作台excel导出版本2
     *
     * @param deviceName
     * @param sheet
     * @param style
     * @param workbenchModel
     */
    private void excelForMonthAllInGZT(String deviceName, HSSFSheet sheet,
                                       HSSFCellStyle style, List<WorkbenchModel> workbenchModel) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        HSSFRow row = null;
        HSSFCell cell = null;
        for (int j = 0; j < 3; j++) {
            row = sheet.createRow(j);
            sheet.getRow(j).setHeightInPoints(40);
            for (int i = 0; i < 24; i++) {
                cell = row.createCell(i);
            }
        }
        sheet.getRow(0).getCell(0).setCellValue(deviceName + "质控");
        sheet.getRow(0).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(0).setCellValue("日期");
        sheet.getRow(1).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(1).setCellValue("操作前");
        sheet.getRow(1).getCell(1).setCellStyle(style);
        sheet.getRow(1).getCell(11).setCellValue("操作后");
        sheet.getRow(1).getCell(11).setCellStyle(style);
        sheet.getRow(1).getCell(21).setCellValue("维护记录");
        sheet.getRow(1).getCell(21).setCellStyle(style);
        sheet.getRow(1).getCell(22).setCellValue("自查说明");
        sheet.getRow(1).getCell(22).setCellStyle(style);
        sheet.getRow(1).getCell(23).setCellValue("审核人");
        sheet.getRow(1).getCell(23).setCellStyle(style);
        sheet.getRow(2).getCell(1).setCellValue("操作时间");
        sheet.getRow(2).getCell(1).setCellStyle(style);
        sheet.getRow(2).getCell(2).setCellValue("操作类型");
        sheet.getRow(2).getCell(2).setCellStyle(style);
        sheet.getRow(2).getCell(3).setCellValue("油量");
        sheet.getRow(2).getCell(3).setCellStyle(style);
        sheet.getRow(2).getCell(4).setCellValue("操作臂行程");
        sheet.getRow(2).getCell(4).setCellStyle(style);
        sheet.getRow(2).getCell(5).setCellValue("温板温度");
        sheet.getRow(2).getCell(5).setCellStyle(style);
        sheet.getRow(2).getCell(6).setCellValue("添加矿物油");
        sheet.getRow(2).getCell(6).setCellStyle(style);
        sheet.getRow(2).getCell(7).setCellValue("光源");
        sheet.getRow(2).getCell(7).setCellStyle(style);
        sheet.getRow(2).getCell(8).setCellValue("激光能量");
        sheet.getRow(2).getCell(8).setCellStyle(style);
        sheet.getRow(2).getCell(9).setCellValue("激光焦点位置");
        sheet.getRow(2).getCell(9).setCellStyle(style);
        sheet.getRow(2).getCell(10).setCellValue("操作者");
        sheet.getRow(2).getCell(10).setCellStyle(style);
        sheet.getRow(2).getCell(11).setCellValue("操作时间");
        sheet.getRow(2).getCell(11).setCellStyle(style);
        sheet.getRow(2).getCell(12).setCellValue("操作类型");
        sheet.getRow(2).getCell(12).setCellStyle(style);
        sheet.getRow(2).getCell(13).setCellValue("油量");
        sheet.getRow(2).getCell(13).setCellStyle(style);
        sheet.getRow(2).getCell(14).setCellValue("操作臂行程");
        sheet.getRow(2).getCell(14).setCellStyle(style);
        sheet.getRow(2).getCell(15).setCellValue("温板温度");
        sheet.getRow(2).getCell(15).setCellStyle(style);
        sheet.getRow(2).getCell(16).setCellValue("添加矿物油");
        sheet.getRow(2).getCell(16).setCellStyle(style);
        sheet.getRow(2).getCell(17).setCellValue("光源");
        sheet.getRow(2).getCell(17).setCellStyle(style);
        sheet.getRow(2).getCell(18).setCellValue("激光能量");
        sheet.getRow(2).getCell(18).setCellStyle(style);
        sheet.getRow(2).getCell(19).setCellValue("激光焦点位置");
        sheet.getRow(2).getCell(19).setCellStyle(style);
        sheet.getRow(2).getCell(20).setCellValue("操作者");
        sheet.getRow(2).getCell(20).setCellStyle(style);
        sheet.getRow(2).getCell(21).setCellValue("维护记录");
        sheet.getRow(2).getCell(21).setCellStyle(style);
        CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 23);
        sheet.addMergedRegion(region1);
        CellRangeAddress region2 = new CellRangeAddress(1, 2, 0, 0);
        sheet.addMergedRegion(region2);
        CellRangeAddress region3 = new CellRangeAddress(1, 1, 1, 10);
        sheet.addMergedRegion(region3);
        CellRangeAddress region4 = new CellRangeAddress(1, 1, 11, 20);
        sheet.addMergedRegion(region4);
        CellRangeAddress region5 = new CellRangeAddress(1, 2, 21, 21);
        sheet.addMergedRegion(region5);
        CellRangeAddress region6 = new CellRangeAddress(1, 2, 22, 22);
        sheet.addMergedRegion(region6);
        CellRangeAddress region7 = new CellRangeAddress(1, 2, 23, 23);
        sheet.addMergedRegion(region7);
        if (CollectionUtils.isNotEmpty(workbenchModel)) {
            int size = workbenchModel.size();
            for (int k = 0; k < size; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 24; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(80));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            for (int j = 3; j < size + 3; j++) {
                sheet.getRow(j).getCell(0).setCellValue(workbenchModel.get(j - 3).getDay());
                String time = workbenchModel.get(j - 3).getBeginPollingTime();
                if (StringUtils.isEmpty(time)) {
                    sheet.getRow(j - 3).getCell(1).setCellValue("");
                } else {

                    sheet.getRow(j).getCell(1).setCellValue(time);
                }
                String begintype = workbenchModel.get(j - 3).getWorkbenchOperationTypeBegin();
                if (StringUtils.isEmpty(begintype)) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(2).setCellValue(begintype);
                }
                String oilMassBegin = workbenchModel.get(j - 3).getOilMassBegin();
                if (StringUtils.isEmpty(oilMassBegin)) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    String oilMassBegin2 = changeStatus4(oilMassBegin);
                    sheet.getRow(j).getCell(3).setCellValue(oilMassBegin2);
                }
                String motionArmBegin = workbenchModel.get(j - 3).getMotionArmBegin();
                if (StringUtils.isEmpty(motionArmBegin)) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    String motionArmBegin2 = changeStatus2(motionArmBegin);
                    sheet.getRow(j).getCell(4).setCellValue(motionArmBegin2);
                }
                String wenBoardBegin = workbenchModel.get(j - 3).getWenBoardBegin();
                if (StringUtils.isEmpty(wenBoardBegin)) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    String wenBoardBegin2 = changeStatus2(wenBoardBegin);


                    sheet.getRow(j).getCell(5).setCellValue(wenBoardBegin2);
                }
                String mineralOilBegin = workbenchModel.get(j - 3).getMineralOilBegin();
                if (StringUtils.isEmpty(mineralOilBegin)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    String mineroilBegin2 = changeStatus3(mineralOilBegin);
                    sheet.getRow(j).getCell(6).setCellValue(mineroilBegin2);
                }
                String lightSourceBegin = workbenchModel.get(j - 3).getLightSourceBegin();
                if (StringUtils.isEmpty(lightSourceBegin)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    String lightSourceBegin2 = changeStatus2(lightSourceBegin);
                    sheet.getRow(j).getCell(7).setCellValue(lightSourceBegin2);
                }
                String laserLightSourceBegin = workbenchModel.get(j - 3).getLaserLightSourceBegin();
                if (StringUtils.isEmpty(laserLightSourceBegin)) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    String laserLightSourceBegin2 = changeStatus2(laserLightSourceBegin);
                    sheet.getRow(j).getCell(8).setCellValue(laserLightSourceBegin2);
                }
                String laserFocusPositionBegin = workbenchModel.get(j - 3).getLaserFocusPositionBegin();
                if (StringUtils.isEmpty(laserFocusPositionBegin)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    String laserFocusPositionBegin2 = changeStatus2(laserFocusPositionBegin);
                    sheet.getRow(j).getCell(9).setCellValue(laserFocusPositionBegin2);
                }
                String checkingPeopleNameBegin = workbenchModel.get(j - 3).getCheckingPeopleNameBegin();
                if (StringUtils.isEmpty(checkingPeopleNameBegin)) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(10).setCellValue(checkingPeopleNameBegin);
                }
                String endtime = workbenchModel.get(j - 3).getEndPollingTime();
                if (StringUtils.isEmpty(endtime)) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {

                    sheet.getRow(j).getCell(11).setCellValue(endtime);
                }
                String endtype = workbenchModel.get(j - 3).getWorkbenchOperationTypeBegin();
                if (StringUtils.isEmpty(endtype)) {

                    sheet.getRow(j).getCell(12).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(12).setCellValue(endtype);
                }
                String oilMassEnd = workbenchModel.get(j - 3).getOilMassEnd();
                if (StringUtils.isEmpty(oilMassEnd)) {
                    sheet.getRow(j).getCell(13).setCellValue("");
                } else {
                    String oilMassEnd2 = changeStatus4(oilMassEnd);
                    sheet.getRow(j).getCell(13).setCellValue(oilMassEnd2);
                }
                String motionArmEnd = workbenchModel.get(j - 3).getMotionArmEnd();
                if (StringUtils.isEmpty(motionArmEnd)) {
                    sheet.getRow(j).getCell(14).setCellValue("");
                } else {
                    String motionArmEnd2 = changeStatus2(motionArmEnd);
                    sheet.getRow(j).getCell(14).setCellValue(motionArmEnd2);
                }
                String wenBoardEnd = workbenchModel.get(j - 3).getWenBoardEnd();
                if (StringUtils.isEmpty(wenBoardEnd)) {
                    sheet.getRow(j).getCell(15).setCellValue("");
                } else {
                    String wenBoardEnd2 = changeStatus2(wenBoardEnd);
                    sheet.getRow(j).getCell(15).setCellValue(wenBoardEnd2);
                }
                String mineralOilEnd = workbenchModel.get(j - 3).getMineralOilEnd();
                if (StringUtils.isEmpty(mineralOilEnd)) {
                    sheet.getRow(j).getCell(16).setCellValue("");
                } else {
                    String mineralOilEnd2 = changeStatus3(mineralOilEnd);
                    sheet.getRow(j).getCell(16).setCellValue(mineralOilEnd2);
                }
                String lightSourceEnd = workbenchModel.get(j - 3).getLightSourceEnd();
                if (StringUtils.isEmpty(lightSourceEnd)) {
                    sheet.getRow(j).getCell(17).setCellValue("");
                } else {
                    String lightSourceEnd2 = changeStatus2(lightSourceEnd);
                    sheet.getRow(j).getCell(17).setCellValue(lightSourceEnd2);
                }

                String laserLightSourceEnd = workbenchModel.get(j - 3).getLaserLightSourceEnd();

                if (StringUtils.isEmpty(laserLightSourceEnd)) {
                    sheet.getRow(j).getCell(18).setCellValue("");
                } else {
                    String laserLightSourceEnd2 = changeStatus2(laserLightSourceEnd);

                    sheet.getRow(j).getCell(18).setCellValue(laserLightSourceEnd2);
                }

                String laserFocusPositionEnd = workbenchModel.get(j - 3).getLaserFocusPositionEnd();
                if (StringUtils.isEmpty(laserFocusPositionEnd)) {

                    sheet.getRow(j).getCell(19).setCellValue("");
                } else {
                    String laserFocusPositionEnd2 = changeStatus2(laserFocusPositionEnd);
                    sheet.getRow(j).getCell(19).setCellValue(laserFocusPositionEnd2);
                }
                String checkingPeopleNameEnd = workbenchModel.get(j - 3).getCheckingPeopleNameEnd();
                if (StringUtils.isEmpty(checkingPeopleNameEnd)) {
                    sheet.getRow(j).getCell(20).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(20).setCellValue(checkingPeopleNameEnd);
                }
                String maintenanceRecord = workbenchModel.get(j - 3).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(21).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(21).setCellValue(maintenanceRecord);
                }
                String selfCheck = workbenchModel.get(j - 3).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(22).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(22).setCellValue(selfCheck);
                }
                String checker = workbenchModel.get(j - 3).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(23).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(23).setCellValue(checker);
                }
            }
        }
    }

    /**
     * 环境excel导出版本2
     *
     * @param deviceName
     * @param sheet
     * @param style
     * @param list
     */
    private void excelForMonthAllInHJ(String deviceName, HSSFSheet sheet,
                                      HSSFCellStyle style, List<QualityControlReportList> list) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        HSSFRow row = null;
        HSSFCell cell = null;
        for (int j = 0; j < 3; j++) {
            row = sheet.createRow(j);
            sheet.getRow(j).setHeightInPoints(40);
            for (int i = 0; i < 20; i++) {
                cell = row.createCell(i);
            }
        }
        sheet.getRow(0).getCell(0).setCellValue(deviceName + "质控");
        sheet.getRow(0).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(0).setCellValue("日期");
        sheet.getRow(1).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(1).setCellValue("时间");
        sheet.getRow(1).getCell(1).setCellStyle(style);
        sheet.getRow(1).getCell(2).setCellValue("温度");
        sheet.getRow(1).getCell(2).setCellStyle(style);
        sheet.getRow(1).getCell(3).setCellValue("湿度");
        sheet.getRow(1).getCell(3).setCellStyle(style);
        sheet.getRow(1).getCell(4).setCellValue("VOC(PPM)");
        sheet.getRow(1).getCell(4).setCellStyle(style);
        sheet.getRow(1).getCell(5).setCellValue("PM2.5(带单位)");
        sheet.getRow(1).getCell(5).setCellStyle(style);
        sheet.getRow(1).getCell(6).setCellValue("PM10(带单位)");
        sheet.getRow(1).getCell(6).setCellStyle(style);
        sheet.getRow(1).getCell(7).setCellValue("氧气浓度(带单位)");
        sheet.getRow(1).getCell(7).setCellStyle(style);
        sheet.getRow(1).getCell(8).setCellValue("二氧化碳浓度(带单位)");
        sheet.getRow(1).getCell(8).setCellStyle(style);
        sheet.getRow(1).getCell(9).setCellValue("甲醛(带单位)");
        sheet.getRow(1).getCell(9).setCellStyle(style);
        sheet.getRow(1).getCell(10).setCellValue("压力(带单位)");
        sheet.getRow(1).getCell(10).setCellStyle(style);
        sheet.getRow(1).getCell(11).setCellValue("上班巡检");
        sheet.getRow(1).getCell(11).setCellStyle(style);
        sheet.getRow(1).getCell(14).setCellValue("下班巡检");
        sheet.getRow(1).getCell(14).setCellStyle(style);
        sheet.getRow(1).getCell(17).setCellValue("维护记录");
        sheet.getRow(1).getCell(17).setCellStyle(style);
        sheet.getRow(1).getCell(18).setCellValue("自查说明");
        sheet.getRow(1).getCell(18).setCellStyle(style);
        sheet.getRow(1).getCell(19).setCellValue("审核人");
        sheet.getRow(1).getCell(19).setCellStyle(style);
        sheet.getRow(2).getCell(11).setCellValue("巡检时间");
        sheet.getRow(2).getCell(11).setCellStyle(style);
        sheet.getRow(2).getCell(12).setCellValue("巡检状态");
        sheet.getRow(2).getCell(12).setCellStyle(style);
        sheet.getRow(2).getCell(13).setCellValue("巡检者");
        sheet.getRow(2).getCell(13).setCellStyle(style);
        sheet.getRow(2).getCell(14).setCellValue("巡检时间");
        sheet.getRow(2).getCell(14).setCellStyle(style);
        sheet.getRow(2).getCell(15).setCellValue("巡检状态");
        sheet.getRow(2).getCell(15).setCellStyle(style);
        sheet.getRow(2).getCell(16).setCellValue("巡检者");
        sheet.getRow(2).getCell(16).setCellStyle(style);
        CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 19);
        sheet.addMergedRegion(region1);
        CellRangeAddress region2 = new CellRangeAddress(1, 2, 0, 0);
        sheet.addMergedRegion(region2);
        CellRangeAddress region3 = new CellRangeAddress(1, 2, 1, 1);
        sheet.addMergedRegion(region3);
        CellRangeAddress region4 = new CellRangeAddress(1, 2, 2, 2);
        sheet.addMergedRegion(region4);
        CellRangeAddress region5 = new CellRangeAddress(1, 2, 3, 3);
        sheet.addMergedRegion(region5);
        CellRangeAddress region6 = new CellRangeAddress(1, 2, 4, 4);
        sheet.addMergedRegion(region6);
        CellRangeAddress region7 = new CellRangeAddress(1, 2, 5, 5);
        sheet.addMergedRegion(region7);
        CellRangeAddress region8 = new CellRangeAddress(1, 2, 6, 6);
        sheet.addMergedRegion(region8);
        CellRangeAddress region9 = new CellRangeAddress(1, 2, 7, 7);
        sheet.addMergedRegion(region9);
        CellRangeAddress region10 = new CellRangeAddress(1, 2, 8, 8);
        sheet.addMergedRegion(region10);
        CellRangeAddress region11 = new CellRangeAddress(1, 2, 9, 9);
        sheet.addMergedRegion(region11);
        CellRangeAddress region12 = new CellRangeAddress(1, 2, 10, 10);
        sheet.addMergedRegion(region12);
        CellRangeAddress region13 = new CellRangeAddress(1, 1, 11, 13);
        sheet.addMergedRegion(region13);
        CellRangeAddress region14 = new CellRangeAddress(1, 1, 14, 16);
        sheet.addMergedRegion(region14);
        CellRangeAddress region15 = new CellRangeAddress(1, 2, 17, 17);
        sheet.addMergedRegion(region15);
        CellRangeAddress region16 = new CellRangeAddress(1, 2, 18, 18);
        sheet.addMergedRegion(region16);
        CellRangeAddress region17 = new CellRangeAddress(1, 2, 19, 19);
        sheet.addMergedRegion(region17);
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size * 4; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 20; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(72));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            int count;
            int temp = 0;
            for (int j = 3; j < size * 4 + 3; j++) {
                if (j - 3 <= 3) {
                    count = j - 3;
                } else if ((j - 3) % 4 == 0) {
                    count = 0;
                    temp = j;
                } else {
                    count = j - temp;
                }
                sheet.getRow(j).getCell(0).setCellValue(list.get((int) (Math.floor((j - 3) / 4))).getDate());
                String time = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getTime();
                if (StringUtils.isEmpty(time)) {
                    sheet.getRow(j).getCell(1).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(1).setCellValue(time);
                }
                String environmentTemperature = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentTemperature();
                if (StringUtils.isEmpty(environmentTemperature)) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(2).setCellValue(environmentTemperature);
                }
                String environmentHumidity = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentHumidity();
                if (StringUtils.isEmpty(environmentHumidity)) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(3).setCellValue(environmentHumidity);
                }
                String environmentVOC = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentVOC();
                if (StringUtils.isEmpty(environmentVOC)) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(4).setCellValue(environmentVOC);
                }
                String environmentPM2 = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentPM2();
                if (StringUtils.isEmpty(environmentPM2)) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(5).setCellValue(environmentPM2);
                }
                String environmentPM10 = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentPM10();
                if (StringUtils.isEmpty(environmentPM10)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(6).setCellValue(environmentPM10);
                }
                String environmentOxygenConcentration = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentOxygenConcentration();
                if (StringUtils.isEmpty(environmentOxygenConcentration)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(environmentOxygenConcentration);
                }
                String environmentCarbonDioxideConcentration = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentCarbonDioxideConcentration();
                if (StringUtils.isEmpty(environmentCarbonDioxideConcentration)) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(8).setCellValue(environmentCarbonDioxideConcentration);
                }
                String environmentMethanal = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentMethanal();
                if (StringUtils.isEmpty(environmentMethanal)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(9).setCellValue(environmentMethanal);
                }
                String environmentPressure = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentPressure();
                if (StringUtils.isEmpty(environmentPressure)) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(10).setCellValue(environmentPressure);
                }
                Date inspectionTimeOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getInspectionTimeOnWork();
                if (inspectionTimeOnWork == null) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {
                    String timeOnWork = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(11).setCellValue(timeOnWork);
                }
                String runningStatusOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getRunningStatusOnWork();
                if (StringUtils.isEmpty(runningStatusOnWork)) {
                    sheet.getRow(j).getCell(12).setCellValue("");
                } else {
                    String runningStatusOnWorkStr = changeStatus(runningStatusOnWork);
                    sheet.getRow(j).getCell(12).setCellValue(runningStatusOnWorkStr);
                }
                String checkingPeopleNameOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(13).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(13).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getInspectionTimeOffWork();
                if (inspectionTimeOffWork == null) {
                    sheet.getRow(j).getCell(14).setCellValue("");
                } else {
                    String timeOffWork = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(14).setCellValue(timeOffWork);
                }
                String runningStatusOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getRunningStatusOffWork();
                if (StringUtils.isEmpty(runningStatusOffWork)) {
                    sheet.getRow(j).getCell(15).setCellValue("");
                } else {
                    String runningStatusOffWorkStr = changeStatus(runningStatusOffWork);
                    sheet.getRow(j).getCell(15).setCellValue(runningStatusOffWorkStr);
                }
                String checkingPeopleNameOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(16).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(16).setCellValue(checkingPeopleNameOffWork);
                }
                String maintenanceRecord = list.get((int) (Math.floor((j - 3) / 4))).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(17).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(17).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get((int) (Math.floor((j - 3) / 4))).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(18).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(18).setCellValue(selfCheck);
                }
                String checker = list.get((int) (Math.floor((j - 3) / 4))).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(19).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(19).setCellValue(checker);
                }
            }
            for (int j = 0; j < list.size(); j++) {
                CellRangeAddress region18 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 17, 17);
                sheet.addMergedRegion(region18);
                CellRangeAddress region19 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 18, 18);
                sheet.addMergedRegion(region19);
                CellRangeAddress region20 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 19, 19);
                sheet.addMergedRegion(region20);
            }
        }
    }

    /**
     * 显微镜excel导出版本2
     *
     * @param deviceName
     * @param sheet
     * @param style
     * @param list
     */
    private void excelForMonthAllInXWJ(String deviceName, HSSFSheet sheet,
                                       HSSFCellStyle style, List<QualityControlReportList> list) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        HSSFRow row = null;
        HSSFCell cell = null;
        for (int j = 0; j < 3; j++) {
            row = sheet.createRow(j);
            sheet.getRow(j).setHeightInPoints(40);
            for (int i = 0; i < 12; i++) {
                cell = row.createCell(i);
            }
        }
        sheet.getRow(0).getCell(0).setCellValue(deviceName + "质控");
        sheet.getRow(0).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(0).setCellValue("日期");
        sheet.getRow(1).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(1).setCellValue("开始巡检");
        sheet.getRow(1).getCell(1).setCellStyle(style);
        sheet.getRow(1).getCell(5).setCellValue("结束巡检");
        sheet.getRow(1).getCell(5).setCellStyle(style);
        sheet.getRow(1).getCell(9).setCellValue("维护记录");
        sheet.getRow(1).getCell(9).setCellStyle(style);
        sheet.getRow(1).getCell(10).setCellValue("自查说明");
        sheet.getRow(1).getCell(10).setCellStyle(style);
        sheet.getRow(1).getCell(11).setCellValue("审核人");
        sheet.getRow(1).getCell(11).setCellStyle(style);
        sheet.getRow(2).getCell(1).setCellValue("巡检时间");
        sheet.getRow(2).getCell(1).setCellStyle(style);
        sheet.getRow(2).getCell(2).setCellValue("运行状态");
        sheet.getRow(2).getCell(2).setCellStyle(style);
        sheet.getRow(2).getCell(3).setCellValue("备注");
        sheet.getRow(2).getCell(3).setCellStyle(style);
        sheet.getRow(2).getCell(4).setCellValue("巡检者");
        sheet.getRow(2).getCell(4).setCellStyle(style);
        sheet.getRow(2).getCell(5).setCellValue("巡检时间");
        sheet.getRow(2).getCell(5).setCellStyle(style);
        sheet.getRow(2).getCell(6).setCellValue("运行状态");
        sheet.getRow(2).getCell(6).setCellStyle(style);
        sheet.getRow(2).getCell(7).setCellValue("备注");
        sheet.getRow(2).getCell(7).setCellStyle(style);
        sheet.getRow(2).getCell(8).setCellValue("巡检者");
        sheet.getRow(2).getCell(8).setCellStyle(style);
        CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 11);
        sheet.addMergedRegion(region1);
        CellRangeAddress region2 = new CellRangeAddress(1, 2, 0, 0);
        sheet.addMergedRegion(region2);
        CellRangeAddress region3 = new CellRangeAddress(1, 1, 1, 4);
        sheet.addMergedRegion(region3);
        CellRangeAddress region4 = new CellRangeAddress(1, 1, 5, 8);
        sheet.addMergedRegion(region4);
        CellRangeAddress region5 = new CellRangeAddress(1, 2, 9, 9);
        sheet.addMergedRegion(region5);
        CellRangeAddress region6 = new CellRangeAddress(1, 2, 10, 10);
        sheet.addMergedRegion(region6);
        CellRangeAddress region7 = new CellRangeAddress(1, 2, 11, 11);
        sheet.addMergedRegion(region7);
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 12; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(120));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            for (int j = 3; j < list.size() + 3; j++) {
                sheet.getRow(j).getCell(0).setCellValue(list.get(j - 3).getDate());
                Date inspectionTimeOnWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOnWork();
                if (inspectionTimeOnWork == null) {
                    sheet.getRow(j).getCell(1).setCellValue("");
                } else {
                    String timeOnWork = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(1).setCellValue(timeOnWork);
                }
                String runningStatusOnWork = list.get(j - 3).getQcrs().get(0).getRunningStatusOnWork();
                if (StringUtils.isEmpty(runningStatusOnWork)) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    String runningStatusOnWorkStr = changeStatus(runningStatusOnWork);
                    sheet.getRow(j).getCell(2).setCellValue(runningStatusOnWorkStr);
                }
                String remarkOnWork = list.get(j - 3).getQcrs().get(0).getRemarkOnWork();
                if (StringUtils.isEmpty(remarkOnWork)) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(3).setCellValue(remarkOnWork);
                }
                String checkingPeopleNameOnWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(4).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOffWork();
                if (inspectionTimeOffWork == null) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    String timeOffWork = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(5).setCellValue(timeOffWork);
                }
                String runningStatusOffWork = list.get(j - 3).getQcrs().get(0).getRunningStatusOffWork();
                if (StringUtils.isEmpty(runningStatusOffWork)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    String runningStatusOffWorkStr = changeStatus(runningStatusOffWork);
                    sheet.getRow(j).getCell(6).setCellValue(runningStatusOffWorkStr);
                }
                String remarkOffWork = list.get(j - 3).getQcrs().get(0).getRemarkOffWork();
                if (StringUtils.isEmpty(remarkOffWork)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(remarkOffWork);
                }
                String checkingPeopleNameOffWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(8).setCellValue(checkingPeopleNameOffWork);
                }
                String maintenanceRecord = list.get(j - 3).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(9).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get(j - 3).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(10).setCellValue(selfCheck);
                }
                String checker = list.get(j - 3).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(11).setCellValue(checker);
                }
            }
        }
    }

    /**
     * 工作站和离心机excel导出版本2
     *
     * @param deviceName
     * @param sheet
     * @param style
     * @param list
     */
    private void excelForMonthAllInGZZOrLXJ(String deviceName, HSSFSheet sheet,
                                            HSSFCellStyle style, List<QualityControlReportList> list,String classifyId) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        HSSFRow row = null;
        HSSFCell cell = null;
        for (int j = 0; j < 3; j++) {
            row = sheet.createRow(j);
            sheet.getRow(j).setHeightInPoints(40);
            for (int i = 0; i < 10; i++) {
                cell = row.createCell(i);
            }
        }
        sheet.getRow(0).getCell(0).setCellValue(deviceName + "质控");
        sheet.getRow(0).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(0).setCellValue("日期");
        sheet.getRow(1).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(1).setCellValue("开始巡检");
        sheet.getRow(1).getCell(1).setCellStyle(style);
        sheet.getRow(1).getCell(4).setCellValue("结束巡检");
        sheet.getRow(1).getCell(4).setCellStyle(style);
        sheet.getRow(1).getCell(7).setCellValue("维护记录");
        sheet.getRow(1).getCell(7).setCellStyle(style);
        sheet.getRow(1).getCell(8).setCellValue("自查说明");
        sheet.getRow(1).getCell(8).setCellStyle(style);
        sheet.getRow(1).getCell(9).setCellValue("审核人");
        sheet.getRow(1).getCell(9).setCellStyle(style);
        sheet.getRow(2).getCell(1).setCellValue("巡检时间");
        sheet.getRow(2).getCell(1).setCellStyle(style);
        sheet.getRow(2).getCell(2).setCellValue("运行状态");
        sheet.getRow(2).getCell(2).setCellStyle(style);
        sheet.getRow(2).getCell(3).setCellValue("巡检者");
        sheet.getRow(2).getCell(3).setCellStyle(style);
        sheet.getRow(2).getCell(4).setCellValue("巡检时间");
        sheet.getRow(2).getCell(4).setCellStyle(style);
        sheet.getRow(2).getCell(5).setCellValue("运行状态");
        sheet.getRow(2).getCell(5).setCellStyle(style);
        sheet.getRow(2).getCell(6).setCellValue("巡检者");
        sheet.getRow(2).getCell(6).setCellStyle(style);
        CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 9);
        sheet.addMergedRegion(region1);
        CellRangeAddress region2 = new CellRangeAddress(1, 2, 0, 0);
        sheet.addMergedRegion(region2);
        CellRangeAddress region3 = new CellRangeAddress(1, 1, 1, 3);
        sheet.addMergedRegion(region3);
        CellRangeAddress region4 = new CellRangeAddress(1, 1, 4, 6);
        sheet.addMergedRegion(region4);
        CellRangeAddress region5 = new CellRangeAddress(1, 2, 7, 7);
        sheet.addMergedRegion(region5);
        CellRangeAddress region6 = new CellRangeAddress(1, 2, 8, 8);
        sheet.addMergedRegion(region6);
        CellRangeAddress region7 = new CellRangeAddress(1, 2, 9, 9);
        sheet.addMergedRegion(region7);
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 10; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(145));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            for (int j = 3; j < list.size() + 3; j++) {
                sheet.getRow(j).getCell(0).setCellValue(list.get(j - 3).getDate());
                Date inspectionTimeOnWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOnWork();
                if (inspectionTimeOnWork == null) {
                    sheet.getRow(j).getCell(1).setCellValue("");
                } else {
                    String timeOnWork = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(1).setCellValue(timeOnWork);
                }
                String runningStatusOnWork = list.get(j - 3).getQcrs().get(0).getRunningStatusOnWork();
                if (StringUtils.isEmpty(runningStatusOnWork)) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    String runningStatusOnWorkStr;
                    if (StringUtils.equals("5",classifyId)){
                        runningStatusOnWorkStr = changeStatusByGZZ(runningStatusOnWork);
                    }else {
                        runningStatusOnWorkStr = changeStatus(runningStatusOnWork);
                    }
                    sheet.getRow(j).getCell(2).setCellValue(runningStatusOnWorkStr);
                }
                String checkingPeopleNameOnWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(3).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOffWork();
                if (inspectionTimeOffWork == null) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    String timeOffWork = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(4).setCellValue(timeOffWork);
                }
                String runningStatusOffWork = list.get(j - 3).getQcrs().get(0).getRunningStatusOffWork();
                if (StringUtils.isEmpty(runningStatusOffWork)) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    String runningStatusOffWorkStr;
                    if (StringUtils.equals("5",classifyId)){
                        runningStatusOffWorkStr = changeStatusByGZZ(runningStatusOffWork);
                    }else {
                        runningStatusOffWorkStr = changeStatus(runningStatusOffWork);
                    }
                    sheet.getRow(j).getCell(5).setCellValue(runningStatusOffWorkStr);
                }
                String checkingPeopleNameOffWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(6).setCellValue(checkingPeopleNameOffWork);
                }
                String maintenanceRecord = list.get(j - 3).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get(j - 3).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(8).setCellValue(selfCheck);
                }
                String checker = list.get(j - 3).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(9).setCellValue(checker);
                }
            }
        }
    }

    /**
     * 培养箱excel导出版本2
     *
     * @param deviceName
     * @param sheet
     * @param style
     * @param list
     */
    private void excelForMonthAllInPYX(String deviceName, HSSFSheet sheet,
                                       HSSFCellStyle style, List<QualityControlReportList> list) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        HSSFRow row = null;
        HSSFCell cell = null;
        for (int j = 0; j < 3; j++) {
            row = sheet.createRow(j);
            sheet.getRow(j).setHeightInPoints(40);
            for (int i = 0; i < 19; i++) {
                cell = row.createCell(i);
            }
        }
        sheet.getRow(0).getCell(0).setCellValue(deviceName + "质控");
        sheet.getRow(0).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(0).setCellValue("日期");
        sheet.getRow(1).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(1).setCellValue("时间");
        sheet.getRow(1).getCell(1).setCellStyle(style);
        sheet.getRow(1).getCell(2).setCellValue("机器自身数据 (MT700)");
        sheet.getRow(1).getCell(2).setCellStyle(style);
        sheet.getRow(1).getCell(6).setCellValue("第三方数据");
        sheet.getRow(1).getCell(6).setCellStyle(style);
        sheet.getRow(1).getCell(10).setCellValue("上班巡检");
        sheet.getRow(1).getCell(10).setCellStyle(style);
        sheet.getRow(1).getCell(13).setCellValue("下班巡检");
        sheet.getRow(1).getCell(13).setCellStyle(style);
        sheet.getRow(1).getCell(16).setCellValue("维护记录");
        sheet.getRow(1).getCell(16).setCellStyle(style);
        sheet.getRow(1).getCell(17).setCellValue("自查说明");
        sheet.getRow(1).getCell(17).setCellStyle(style);
        sheet.getRow(1).getCell(18).setCellValue("审核人");
        sheet.getRow(1).getCell(18).setCellStyle(style);
        sheet.getRow(2).getCell(2).setCellValue("温度");
        sheet.getRow(2).getCell(2).setCellStyle(style);
        sheet.getRow(2).getCell(3).setCellValue("湿度");
        sheet.getRow(2).getCell(3).setCellStyle(style);
        sheet.getRow(2).getCell(4).setCellValue("CO2浓度");
        sheet.getRow(2).getCell(4).setCellStyle(style);
        sheet.getRow(2).getCell(5).setCellValue("O2浓度");
        sheet.getRow(2).getCell(5).setCellStyle(style);
        sheet.getRow(2).getCell(6).setCellValue("温度1 (MT100)");
        sheet.getRow(2).getCell(6).setCellStyle(style);
        sheet.getRow(2).getCell(7).setCellValue("温度2 (MT300)");
        sheet.getRow(2).getCell(7).setCellStyle(style);
        sheet.getRow(2).getCell(8).setCellValue("C02浓度 (MT300)");
        sheet.getRow(2).getCell(8).setCellStyle(style);
        sheet.getRow(2).getCell(9).setCellValue("02浓度");
        sheet.getRow(2).getCell(9).setCellStyle(style);
        sheet.getRow(2).getCell(10).setCellValue("巡检时间");
        sheet.getRow(2).getCell(10).setCellStyle(style);
        sheet.getRow(2).getCell(11).setCellValue("巡检状态");
        sheet.getRow(2).getCell(11).setCellStyle(style);
        sheet.getRow(2).getCell(12).setCellValue("巡检者");
        sheet.getRow(2).getCell(12).setCellStyle(style);
        sheet.getRow(2).getCell(13).setCellValue("巡检时间");
        sheet.getRow(2).getCell(13).setCellStyle(style);
        sheet.getRow(2).getCell(14).setCellValue("巡检状态");
        sheet.getRow(2).getCell(14).setCellStyle(style);
        sheet.getRow(2).getCell(15).setCellValue("巡检者");
        sheet.getRow(2).getCell(15).setCellStyle(style);
        CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 18);
        sheet.addMergedRegion(region1);
        CellRangeAddress region2 = new CellRangeAddress(1, 2, 0, 0);
        sheet.addMergedRegion(region2);
        CellRangeAddress region3 = new CellRangeAddress(1, 2, 1, 1);
        sheet.addMergedRegion(region3);
        CellRangeAddress region5 = new CellRangeAddress(1, 1, 2, 5);
        sheet.addMergedRegion(region5);
        CellRangeAddress region7 = new CellRangeAddress(1, 1, 6, 9);
        sheet.addMergedRegion(region7);
        CellRangeAddress region8 = new CellRangeAddress(1, 1, 10, 12);
        sheet.addMergedRegion(region8);
        CellRangeAddress region9 = new CellRangeAddress(1, 1, 13, 15);
        sheet.addMergedRegion(region9);
        CellRangeAddress region10 = new CellRangeAddress(1, 2, 16, 16);
        sheet.addMergedRegion(region10);
        CellRangeAddress region11 = new CellRangeAddress(1, 2, 17, 17);
        sheet.addMergedRegion(region11);
        CellRangeAddress region12 = new CellRangeAddress(1, 2, 18, 18);
        sheet.addMergedRegion(region12);
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size * 4; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 19; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(70));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            int count;
            int temp = 0;
            for (int j = 3; j < size * 4 + 3; j++) {
                if (j - 3 <= 3) {
                    count = j - 3;
                } else if ((j - 3) % 4 == 0) {
                    count = 0;
                    temp = j;
                } else {
                    count = j - temp;
                }
                sheet.getRow(j).getCell(0).setCellValue(list.get((int) (Math.floor((j - 3) / 4))).getDate());
                sheet.getRow(j).getCell(1).setCellValue(list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getTime());
                Double selfTemperatureAvg = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getSelfTemperatureAvg();
                if (selfTemperatureAvg == null) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(2).setCellValue(selfTemperatureAvg);
                }
                Double selfHumidityAvg = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getSelfHumidityAvg();
                if (selfHumidityAvg == null) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(3).setCellValue(selfHumidityAvg);
                }
                Double selfCarbonDioxideConcentration = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getSelfCarbonDioxideConcentration();
                if (selfCarbonDioxideConcentration == null) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(4).setCellValue(selfCarbonDioxideConcentration);
                }
                Double selfOxygenConcentration = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getSelfOxygenConcentration();
                if (selfOxygenConcentration == null) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(5).setCellValue(selfOxygenConcentration);
                }
                Double temperatureAvgMT100 = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getTemperatureAvgMT100();
                if (temperatureAvgMT100 == null) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(6).setCellValue(temperatureAvgMT100);
                }
                Double temperatureAvgMT300 = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getTemperatureAvgMT300();
                if (temperatureAvgMT300 == null) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(temperatureAvgMT300);
                }
                Double carbonDioxideConcentrationMT300 = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getCarbonDioxideConcentrationMT300();
                if (carbonDioxideConcentrationMT300 == null) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(8).setCellValue(carbonDioxideConcentrationMT300);
                }
                Double thirdYqMv = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getThirdYqMv();
                if (thirdYqMv == null) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(9).setCellValue(thirdYqMv);
                }
                Date inspectionTimeOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getInspectionTimeOnWork();
                if (inspectionTimeOnWork == null) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    String inspectionTimeOnWorkStr = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(10).setCellValue(inspectionTimeOnWorkStr);
                }
                String runningStatusOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getRunningStatusOnWork();
                if (StringUtils.isEmpty(runningStatusOnWork)) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {
                    String runningStatusOnWorkStr = changeStatus(runningStatusOnWork);
                    sheet.getRow(j).getCell(11).setCellValue(runningStatusOnWorkStr);
                }
                String checkingPeopleNameOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(12).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(12).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getInspectionTimeOffWork();
                if (inspectionTimeOffWork == null) {
                    sheet.getRow(j).getCell(13).setCellValue("");
                } else {
                    String inspectionTimeOffWorkStr = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(13).setCellValue(inspectionTimeOffWorkStr);
                }
                String runningStatusOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getRunningStatusOffWork();
                if (StringUtils.isEmpty(runningStatusOffWork)) {
                    sheet.getRow(j).getCell(14).setCellValue("");
                } else {
                    String runningStatusOffWorkStr = changeStatus(runningStatusOffWork);
                    sheet.getRow(j).getCell(14).setCellValue(runningStatusOffWorkStr);
                }
                String checkingPeopleNameOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(15).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(15).setCellValue(checkingPeopleNameOffWork);
                }
                String maintenanceRecord = list.get((int) (Math.floor((j - 3) / 4))).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(16).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(16).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get((int) (Math.floor((j - 3) / 4))).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(17).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(17).setCellValue(selfCheck);
                }
                String checker = list.get((int) (Math.floor((j - 3) / 4))).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(18).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(18).setCellValue(checker);
                }
            }
            for (int j = 0; j < list.size(); j++) {
                CellRangeAddress region13 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 16, 16);
                sheet.addMergedRegion(region13);
                CellRangeAddress region14 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 17, 17);
                sheet.addMergedRegion(region14);
                CellRangeAddress region15 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 18, 18);
                sheet.addMergedRegion(region15);
            }
        }
    }

    /**
     * 胚胎库excel导出版本2
     *
     * @param deviceName
     * @param sheet
     * @param style
     * @param list
     */
    private void excelForMonthAllInPTK(String deviceName, HSSFSheet sheet,
                                       HSSFCellStyle style, List<QualityControlReportList> list) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        HSSFRow row = null;
        HSSFCell cell = null;
        for (int j = 0; j < 3; j++) {
            row = sheet.createRow(j);
            sheet.getRow(j).setHeightInPoints(40);
            for (int i = 0; i < 19; i++) {
                cell = row.createCell(i);
            }
        }
        sheet.getRow(0).getCell(0).setCellValue(deviceName + "质控");
        sheet.getRow(0).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(0).setCellValue("日期");
        sheet.getRow(1).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(1).setCellValue("上班巡检");
        sheet.getRow(1).getCell(1).setCellStyle(style);
        sheet.getRow(1).getCell(8).setCellValue("下班巡检");
        sheet.getRow(1).getCell(8).setCellStyle(style);
        sheet.getRow(1).getCell(15).setCellValue("是否添加液氮");
        sheet.getRow(1).getCell(15).setCellStyle(style);
        sheet.getRow(1).getCell(16).setCellValue("维护记录");
        sheet.getRow(1).getCell(16).setCellStyle(style);
        sheet.getRow(1).getCell(17).setCellValue("自查说明");
        sheet.getRow(1).getCell(17).setCellStyle(style);
        sheet.getRow(1).getCell(18).setCellValue("审核人");
        sheet.getRow(1).getCell(18).setCellStyle(style);
        sheet.getRow(2).getCell(1).setCellValue("巡检时间");
        sheet.getRow(2).getCell(1).setCellStyle(style);
        sheet.getRow(2).getCell(2).setCellValue("监控系统");
        sheet.getRow(2).getCell(2).setCellStyle(style);
        sheet.getRow(2).getCell(3).setCellValue("液氮罐锁");
        sheet.getRow(2).getCell(3).setCellStyle(style);
        sheet.getRow(2).getCell(4).setCellValue("液氮罐锁备注");
        sheet.getRow(2).getCell(4).setCellStyle(style);
        sheet.getRow(2).getCell(5).setCellValue("罐体温度");
        sheet.getRow(2).getCell(5).setCellStyle(style);
        sheet.getRow(2).getCell(6).setCellValue("罐体温度备注");
        sheet.getRow(2).getCell(6).setCellStyle(style);
        sheet.getRow(2).getCell(7).setCellValue("巡检者");
        sheet.getRow(2).getCell(7).setCellStyle(style);
        sheet.getRow(2).getCell(8).setCellValue("巡检时间");
        sheet.getRow(2).getCell(8).setCellStyle(style);
        sheet.getRow(2).getCell(9).setCellValue("监控系统");
        sheet.getRow(2).getCell(9).setCellStyle(style);
        sheet.getRow(2).getCell(10).setCellValue("液氮罐锁");
        sheet.getRow(2).getCell(10).setCellStyle(style);
        sheet.getRow(2).getCell(11).setCellValue("液氮罐锁备注");
        sheet.getRow(2).getCell(11).setCellStyle(style);
        sheet.getRow(2).getCell(12).setCellValue("罐体温度");
        sheet.getRow(2).getCell(12).setCellStyle(style);
        sheet.getRow(2).getCell(13).setCellValue("罐体温度备注");
        sheet.getRow(2).getCell(13).setCellStyle(style);
        sheet.getRow(2).getCell(14).setCellValue("巡检者");
        sheet.getRow(2).getCell(14).setCellStyle(style);
        CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 17);
        sheet.addMergedRegion(region1);
        CellRangeAddress region2 = new CellRangeAddress(1, 2, 0, 0);
        sheet.addMergedRegion(region2);
        CellRangeAddress region3 = new CellRangeAddress(1, 1, 1, 7);
        sheet.addMergedRegion(region3);
        CellRangeAddress region4 = new CellRangeAddress(1, 1, 8, 14);
        sheet.addMergedRegion(region4);
        CellRangeAddress region5 = new CellRangeAddress(1, 2, 15, 15);
        sheet.addMergedRegion(region5);
        CellRangeAddress region6 = new CellRangeAddress(1, 2, 16, 16);
        sheet.addMergedRegion(region6);
        CellRangeAddress region7 = new CellRangeAddress(1, 2, 17, 17);
        sheet.addMergedRegion(region7);
        CellRangeAddress region8 = new CellRangeAddress(1, 2, 18, 18);
        sheet.addMergedRegion(region8);
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 19; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(80));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            for (int j = 3; j < list.size() + 3; j++) {
                sheet.getRow(j).getCell(0).setCellValue(list.get(j - 3).getDate());
                Date inspectionTimeOnWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOnWork();
                if (null == inspectionTimeOnWork) {
                    sheet.getRow(j).getCell(1).setCellValue("");
                } else {
                    String timeOnWork = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(1).setCellValue(timeOnWork);
                }
                String monitoringSystemOnWork = list.get(j - 3).getQcrs().get(0).getMonitoringSystemOnWork();
                if (StringUtils.isEmpty(monitoringSystemOnWork)) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    String monitoringSystemOnWorkStr = changeStatus2(monitoringSystemOnWork);
                    sheet.getRow(j).getCell(2).setCellValue(monitoringSystemOnWorkStr);
                }
                String canisterLockOnWork = list.get(j - 3).getQcrs().get(0).getCanisterLockOnWork();
                if (StringUtils.isEmpty(canisterLockOnWork)) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    String canisterLockOnWorkStr = changeStatus2(canisterLockOnWork);
                    sheet.getRow(j).getCell(3).setCellValue(canisterLockOnWorkStr);
                }
                String tankLockInfoOnWork = list.get(j - 3).getQcrs().get(0).getTankLockInfoOnWork();
                if (StringUtils.isEmpty(tankLockInfoOnWork)) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(4).setCellValue(tankLockInfoOnWork);
                }
                String canisterTemperatureOnWork = list.get(j - 3).getQcrs().get(0).getCanisterTemperatureOnWork();
                if (StringUtils.isEmpty(canisterTemperatureOnWork)) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    String canisterTemperatureOnWorkStr = changeStatus2(canisterTemperatureOnWork);
                    sheet.getRow(j).getCell(5).setCellValue(canisterTemperatureOnWorkStr);
                }
                String tankTemperatureInfoOnWork = list.get(j - 3).getQcrs().get(0).getTankTemperatureInfoOnWork();
                if (StringUtils.isEmpty(tankTemperatureInfoOnWork)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(6).setCellValue(tankTemperatureInfoOnWork);
                }
                String checkingPeopleNameOnWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOffWork();
                if (null == inspectionTimeOffWork) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    String timeOffWork = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(8).setCellValue(timeOffWork);
                }
                String monitoringSystemOffWork = list.get(j - 3).getQcrs().get(0).getMonitoringSystemOffWork();
                if (StringUtils.isEmpty(monitoringSystemOffWork)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    String monitoringSystemOffWorkStr = changeStatus2(monitoringSystemOffWork);
                    sheet.getRow(j).getCell(9).setCellValue(monitoringSystemOffWorkStr);
                }
                String canisterLockOffWork = list.get(j - 3).getQcrs().get(0).getCanisterLockOffWork();
                if (StringUtils.isEmpty(canisterLockOffWork)) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    String canisterLockOffWorkStr = changeStatus2(canisterLockOffWork);
                    sheet.getRow(j).getCell(10).setCellValue(canisterLockOffWorkStr);
                }
                String tankLockInfoOffWork = list.get(j - 3).getQcrs().get(0).getTankLockInfoOffWork();
                if (StringUtils.isEmpty(tankLockInfoOffWork)) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(11).setCellValue(tankLockInfoOffWork);
                }
                String canisterTemperatureOffWork = list.get(j - 3).getQcrs().get(0).getCanisterTemperatureOffWork();
                if (StringUtils.isEmpty(canisterTemperatureOffWork)) {
                    sheet.getRow(j).getCell(12).setCellValue("");
                } else {
                    String canisterTemperatureOffWorkStr = changeStatus2(canisterTemperatureOffWork);
                    sheet.getRow(j).getCell(12).setCellValue(canisterTemperatureOffWorkStr);
                }
                String tankTemperatureInfoOffWork = list.get(j - 3).getQcrs().get(0).getTankTemperatureInfoOffWork();
                if (StringUtils.isEmpty(tankTemperatureInfoOffWork)) {
                    sheet.getRow(j).getCell(13).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(13).setCellValue(tankTemperatureInfoOffWork);
                }
                String checkingPeopleNameOffWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(14).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(14).setCellValue(checkingPeopleNameOffWork);
                }
                String isAddLiquidNitrogen = list.get(j - 3).getIsAddLiquidNitrogen();
                if (StringUtils.isEmpty(isAddLiquidNitrogen)) {
                    sheet.getRow(j).getCell(15).setCellValue("否");
                } else {
                    if (StringUtils.equals("0", isAddLiquidNitrogen)) {
                        sheet.getRow(j).getCell(15).setCellValue("否");
                    } else if (StringUtils.equals("1", isAddLiquidNitrogen)) {
                        sheet.getRow(j).getCell(15).setCellValue("是");
                    }
                }
                String maintenanceRecord = list.get(j - 3).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(16).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(16).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get(j - 3).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(17).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(17).setCellValue(selfCheck);
                }
                String checker = list.get(j - 3).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(18).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(18).setCellValue(checker);
                }
            }
        }
    }


    /**
     * 冰箱excel导出版本2
     *
     * @param deviceName
     * @param sheet
     * @param style
     * @param list
     */
    private void excelForMonthAllInBX(String deviceName, HSSFSheet sheet,
                                      HSSFCellStyle style, List<QualityControlReportList> list) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        HSSFRow row = null;
        HSSFCell cell = null;
        for (int j = 0; j < 3; j++) {
            row = sheet.createRow(j);
            //设置每一列的高度
            sheet.getRow(j).setHeightInPoints(40);
            for (int i = 0; i < 16; i++) {
                cell = row.createCell(i);
            }
        }
        sheet.getRow(0).getCell(0).setCellValue(deviceName + "质控");
        sheet.getRow(0).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(0).setCellValue("日期");
        sheet.getRow(1).getCell(0).setCellStyle(style);
        sheet.getRow(1).getCell(1).setCellValue("时间");
        sheet.getRow(1).getCell(1).setCellStyle(style);
        sheet.getRow(1).getCell(3).setCellValue("上班巡检");
        sheet.getRow(1).getCell(3).setCellStyle(style);
        sheet.getRow(1).getCell(8).setCellValue("下班巡检");
        sheet.getRow(1).getCell(8).setCellStyle(style);
        sheet.getRow(1).getCell(13).setCellValue("维护记录");
        sheet.getRow(1).getCell(13).setCellStyle(style);
        sheet.getRow(1).getCell(14).setCellValue("自查说明");
        sheet.getRow(1).getCell(14).setCellStyle(style);
        sheet.getRow(1).getCell(15).setCellValue("审核人");
        sheet.getRow(1).getCell(15).setCellStyle(style);
        sheet.getRow(2).getCell(2).setCellValue("温度");
        sheet.getRow(2).getCell(2).setCellStyle(style);
        sheet.getRow(2).getCell(3).setCellValue("巡检时间");
        sheet.getRow(2).getCell(3).setCellStyle(style);
        sheet.getRow(2).getCell(4).setCellValue("运行状态");
        sheet.getRow(2).getCell(4).setCellStyle(style);
        sheet.getRow(2).getCell(5).setCellValue("冷藏温度");
        sheet.getRow(2).getCell(5).setCellStyle(style);
        sheet.getRow(2).getCell(6).setCellValue("冷冻温度");
        sheet.getRow(2).getCell(6).setCellStyle(style);
        sheet.getRow(2).getCell(7).setCellValue("巡检者");
        sheet.getRow(2).getCell(7).setCellStyle(style);
        sheet.getRow(2).getCell(8).setCellValue("巡检时间");
        sheet.getRow(2).getCell(8).setCellStyle(style);
        sheet.getRow(2).getCell(9).setCellValue("运行状态");
        sheet.getRow(2).getCell(9).setCellStyle(style);
        sheet.getRow(2).getCell(10).setCellValue("冷藏温度");
        sheet.getRow(2).getCell(10).setCellStyle(style);
        sheet.getRow(2).getCell(11).setCellValue("冷冻温度");
        sheet.getRow(2).getCell(11).setCellStyle(style);
        sheet.getRow(2).getCell(12).setCellValue("巡检者");
        sheet.getRow(2).getCell(12).setCellStyle(style);
        CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 15);
        sheet.addMergedRegion(region1);
        CellRangeAddress region2 = new CellRangeAddress(1, 2, 0, 0);
        sheet.addMergedRegion(region2);
        CellRangeAddress region3 = new CellRangeAddress(1, 2, 1, 1);
        sheet.addMergedRegion(region3);
        CellRangeAddress region5 = new CellRangeAddress(1, 1, 3, 7);
        sheet.addMergedRegion(region5);
        CellRangeAddress region6 = new CellRangeAddress(1, 1, 8, 12);
        sheet.addMergedRegion(region6);
        CellRangeAddress region7 = new CellRangeAddress(1, 2, 13, 13);
        sheet.addMergedRegion(region7);
        CellRangeAddress region8 = new CellRangeAddress(1, 2, 14, 14);
        sheet.addMergedRegion(region8);
        CellRangeAddress region9 = new CellRangeAddress(1, 2, 15, 15);
        sheet.addMergedRegion(region9);
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size * 8; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 16; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(90));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            int count;
            int temp = 0;
            for (int j = 3; j < size * 8 + 3; j++) {
                if (j - 3 <= 7) {
                    count = j - 3;
                } else if ((j - 3) % 8 == 0) {
                    count = 0;
                    temp = j;
                } else {
                    count = j - temp;
                }
                sheet.getRow(j).getCell(0).setCellValue(list.get((int) (Math.floor((j - 3) / 8))).getDate());
                sheet.getRow(j).getCell(1).setCellValue(list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getTime());
                Double getSelfTemperatureAvg = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getSelfTemperatureAvg();
                if (getSelfTemperatureAvg == null) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(2).setCellValue(getSelfTemperatureAvg);
                }
                Date inspectionTimeOnWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getInspectionTimeOnWork();

                if (inspectionTimeOnWork == null) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    String inspectionTimeOnWorkStr = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(3).setCellValue(inspectionTimeOnWorkStr);
                }
                String runningStatusOnWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getRunningStatusOnWork();
                if (StringUtils.isEmpty(runningStatusOnWork)) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    String runningStatusOnWorkStr = changeStatus(runningStatusOnWork);
                    sheet.getRow(j).getCell(4).setCellValue(runningStatusOnWorkStr);
                }
                String coldTemperatureOnWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getColdTemperatureOnWork();
                if (StringUtils.isEmpty(coldTemperatureOnWork)) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(5).setCellValue(coldTemperatureOnWork);
                }
                String freezingTemperatureOnWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getFreezingTemperatureOnWork();
                if (StringUtils.isEmpty(freezingTemperatureOnWork)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(6).setCellValue(freezingTemperatureOnWork);
                }
                String checkingPeopleNameOnWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getInspectionTimeOffWork();
                if (inspectionTimeOffWork == null) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    String inspectionTimeOffWorkStr = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(8).setCellValue(inspectionTimeOffWorkStr);
                }
                String runningStatusOffWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getRunningStatusOffWork();
                if (StringUtils.isEmpty(runningStatusOffWork)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    String runningStatusOffWorkStr = changeStatus(runningStatusOffWork);
                    sheet.getRow(j).getCell(9).setCellValue(runningStatusOffWorkStr);
                }
                String coldTemperatureOffWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getColdTemperatureOffWork();
                if (StringUtils.isEmpty(coldTemperatureOffWork)) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(10).setCellValue(coldTemperatureOffWork);
                }
                String freezingTemperatureOffWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getFreezingTemperatureOffWork();
                if (StringUtils.isEmpty(freezingTemperatureOffWork)) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(11).setCellValue(freezingTemperatureOffWork);
                }
                String checkingPeopleNameOffWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(12).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(12).setCellValue(checkingPeopleNameOffWork);
                }
                String maintenanceRecord = list.get((int) (Math.floor((j - 3) / 8))).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(13).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(13).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get((int) (Math.floor((j - 3) / 8))).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(14).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(14).setCellValue(selfCheck);
                }
                String checker = list.get((int) (Math.floor((j - 3) / 8))).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(15).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(15).setCellValue(checker);
                }
            }
            for (int j = 0; j < list.size(); j++) {
                CellRangeAddress region10 = new CellRangeAddress(j * 8 + 3, j * 8 + 10, 13, 13);
                sheet.addMergedRegion(region10);
                CellRangeAddress region11 = new CellRangeAddress(j * 8 + 3, j * 8 + 10, 14, 14);
                sheet.addMergedRegion(region11);
                CellRangeAddress region12 = new CellRangeAddress(j * 8 + 3, j * 8 + 10, 15, 15);
                sheet.addMergedRegion(region12);
            }
        }
    }

    /**
     * @param response
     * @param eqIds
     * @param startTime
     * @param endTime
     */
    private void excelForMonthAll(HttpServletResponse response, List<Integer> eqIds, String startTime, String endTime, String classifyId) {
        HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
        String fileName = null;
        HSSFCellStyle style = ExcelUtils.getStyle(hssfWorkbook);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for (int w = 0; w < eqIds.size(); w++) {
            Integer eqId = eqIds.get(w);
            //获取数据
            List<QualityControlReportList> list = null;
            List<WorkbenchModel> listGZT = null;
            switch (classifyId) {
                //冰箱
                case "1":
                    list = qcEquipmentRecordService.getQualityControlReportEveryMonthForBX(eqId, startTime, endTime);
                    fileName = "冰箱质控记录查询导出";
                    break;
                //胚胎库
                case "2":
                    list = qcEquipmentRecordService.getQualityControlReportEveryMonthForPTK(eqId, startTime, endTime);
                    fileName = "胚胎库质控记录查询导出";
                    break;
                //培养箱
                case "4":
                    list = qcEquipmentRecordService.getQualityControlReportEveryMonthForPYX(eqId, startTime, endTime);
                    fileName = "培养箱质控记录查询导出";
                    break;
                //工作站
                case "5":
                    list = qcEquipmentRecordService.getQualityControlReportEveryMonthForLXJOrGZZ(eqId, startTime, endTime);
                    fileName = "工作站质控记录查询导出";
                    break;
                //显微镜
                case "6":
                    list = qcEquipmentRecordService.getQualityControlReportEveryMonthForXWJ(eqId, startTime, endTime);
                    fileName = "显微镜质控记录查询导出";
                    break;
                //环境
                case "7":
                    list = qcEquipmentRecordService.getQualityControlReportEveryMonthForHJ(eqId, startTime, endTime);
                    fileName = "环境质控记录查询导出";
                    break;
                case "9":
                    //工作台
                    listGZT = qcEquipmentRecordService.getWorkbenchModelEveryMonthForGZT(eqId, startTime, endTime);
                    fileName = "工作台质控记录查询导出";
                    break;
                //离心机
                case "11":
                    list = qcEquipmentRecordService.getQualityControlReportEveryMonthForLXJOrGZZ(eqId, startTime, endTime);
                    fileName = "离心机质控记录查询导出";
                    break;
            }
            String deviceName = qcEquipmentMapper.selectDeviceNameById(eqId);
            HSSFSheet sheet = hssfWorkbook.createSheet(deviceName);
            if (StringUtils.equals("1", classifyId)) {
                this.excelForMonthAllInBX(deviceName, sheet, style, list);
            } else if (StringUtils.equals("2", classifyId)) {
                this.excelForMonthAllInPTK(deviceName, sheet, style, list);
            } else if (StringUtils.equals("4", classifyId)) {
                this.excelForMonthAllInPYX(deviceName, sheet, style, list);
            } else if (StringUtils.equals("5", classifyId) || StringUtils.equals("11", classifyId)) {
                this.excelForMonthAllInGZZOrLXJ(deviceName, sheet, style, list,classifyId);
            } else if (StringUtils.equals("6", classifyId)) {
                this.excelForMonthAllInXWJ(deviceName, sheet, style, list);
            } else if (StringUtils.equals("7", classifyId)) {
                this.excelForMonthAllInHJ(deviceName, sheet, style, list);
            } else if (StringUtils.equals("9", classifyId)) {
                this.excelForMonthAllInGZT(deviceName, sheet, style, listGZT);
            }
        }
        try {
            ExcelUtils.closeResponse(response, fileName, hssfWorkbook);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 冰箱月质控excel导出
     */
    public void excelBXForMonth(HttpServletResponse response, int eqId, String startTime, String endTime) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取数据
        List<QualityControlReportList> list = qcEquipmentRecordService.getQualityControlReportEveryMonthForBX(eqId, startTime, endTime);
        String nameForBX = qcEquipmentMapper.selectDeviceNameById(eqId);
        //设置冰箱excel表头
        HSSFWorkbook hssfWorkbook = ExcelUtils.setHeaders(3, 16, "冰箱", nameForBX);
        HSSFSheet sheet = hssfWorkbook.getSheet("冰箱每月质控");
        HSSFCellStyle style = ExcelUtils.getStyle(hssfWorkbook);
        HSSFRow row = null;
        HSSFCell cell = null;
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size * 8; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 16; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(90));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            int count;
            int temp = 0;
            for (int j = 3; j < size * 8 + 3; j++) {
                if (j - 3 <= 7) {
                    count = j - 3;
                } else if ((j - 3) % 8 == 0) {
                    count = 0;
                    temp = j;
                } else {
                    count = j - temp;
                }
                sheet.getRow(j).getCell(0).setCellValue(list.get((int) (Math.floor((j - 3) / 8))).getDate());
                sheet.getRow(j).getCell(1).setCellValue(list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getTime());
                Double getSelfTemperatureAvg = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getSelfTemperatureAvg();
                if (getSelfTemperatureAvg == null) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(2).setCellValue(getSelfTemperatureAvg);
                }
                Date inspectionTimeOnWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getInspectionTimeOnWork();

                if (inspectionTimeOnWork == null) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    String inspectionTimeOnWorkStr = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(3).setCellValue(inspectionTimeOnWorkStr);
                }
                String runningStatusOnWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getRunningStatusOnWork();
                if (StringUtils.isEmpty(runningStatusOnWork)) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    String runningStatusOnWorkStr = changeStatus(runningStatusOnWork);
                    sheet.getRow(j).getCell(4).setCellValue(runningStatusOnWorkStr);
                }
                String coldTemperatureOnWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getColdTemperatureOnWork();
                if (StringUtils.isEmpty(coldTemperatureOnWork)) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(5).setCellValue(coldTemperatureOnWork);
                }
                String freezingTemperatureOnWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getFreezingTemperatureOnWork();
                if (StringUtils.isEmpty(freezingTemperatureOnWork)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(6).setCellValue(freezingTemperatureOnWork);
                }
                String checkingPeopleNameOnWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getInspectionTimeOffWork();
                if (inspectionTimeOffWork == null) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    String inspectionTimeOffWorkStr = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(8).setCellValue(inspectionTimeOffWorkStr);
                }
                String runningStatusOffWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getRunningStatusOffWork();
                if (StringUtils.isEmpty(runningStatusOffWork)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    String runningStatusOffWorkStr = changeStatus(runningStatusOffWork);
                    sheet.getRow(j).getCell(9).setCellValue(runningStatusOffWorkStr);
                }
                String coldTemperatureOffWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getColdTemperatureOffWork();
                if (StringUtils.isEmpty(coldTemperatureOffWork)) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(10).setCellValue(coldTemperatureOffWork);
                }
                String freezingTemperatureOffWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getFreezingTemperatureOffWork();
                if (StringUtils.isEmpty(freezingTemperatureOffWork)) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(11).setCellValue(freezingTemperatureOffWork);
                }
                String checkingPeopleNameOffWork = list.get((int) (Math.floor((j - 3) / 8))).getQcrs().get(count).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(12).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(12).setCellValue(checkingPeopleNameOffWork);
                }
                String maintenanceRecord = list.get((int) (Math.floor((j - 3) / 8))).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(13).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(13).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get((int) (Math.floor((j - 3) / 8))).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(14).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(14).setCellValue(selfCheck);
                }
                String checker = list.get((int) (Math.floor((j - 3) / 8))).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(15).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(15).setCellValue(checker);
                }
            }
            for (int j = 0; j < list.size(); j++) {
                CellRangeAddress region10 = new CellRangeAddress(j * 8 + 3, j * 8 + 10, 13, 13);
                sheet.addMergedRegion(region10);
                CellRangeAddress region11 = new CellRangeAddress(j * 8 + 3, j * 8 + 10, 14, 14);
                sheet.addMergedRegion(region11);
                CellRangeAddress region12 = new CellRangeAddress(j * 8 + 3, j * 8 + 10, 15, 15);
                sheet.addMergedRegion(region12);
            }
        }
        try {
            String fileName = "冰箱质控记录查询导出";
            ExcelUtils.closeResponse(response, fileName, hssfWorkbook);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    /**
     * 培养箱每月excel导出
     *
     * @param response
     * @param eqId
     * @param startTime
     * @param endTime
     */
    public void excelPYXForMonth(HttpServletResponse response, int eqId, String startTime, String endTime) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取数据
        List<QualityControlReportList> list = qcEquipmentRecordService.getQualityControlReportEveryMonthForPYX(eqId, startTime, endTime);
        String nameForPYX = qcEquipmentMapper.selectDeviceNameById(eqId);
        HSSFWorkbook hssfWorkbook = ExcelUtils.setHeaders(3, 19, "培养箱", nameForPYX);
        HSSFSheet sheet = hssfWorkbook.getSheet("培养箱每月质控");
        HSSFCellStyle style = ExcelUtils.getStyle(hssfWorkbook);
        HSSFRow row = null;
        HSSFCell cell = null;
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size * 4; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 19; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(70));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            int count;
            int temp = 0;
            for (int j = 3; j < size * 4 + 3; j++) {
                if (j - 3 <= 3) {
                    count = j - 3;
                } else if ((j - 3) % 4 == 0) {
                    count = 0;
                    temp = j;
                } else {
                    count = j - temp;
                }
                sheet.getRow(j).getCell(0).setCellValue(list.get((int) (Math.floor((j - 3) / 4))).getDate());
                sheet.getRow(j).getCell(1).setCellValue(list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getTime());
                Double selfTemperatureAvg = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getSelfTemperatureAvg();
                if (selfTemperatureAvg == null) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(2).setCellValue(selfTemperatureAvg);
                }
                Double selfHumidityAvg = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getSelfHumidityAvg();
                if (selfHumidityAvg == null) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(3).setCellValue(selfHumidityAvg);
                }
                Double selfCarbonDioxideConcentration = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getSelfCarbonDioxideConcentration();
                if (selfCarbonDioxideConcentration == null) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(4).setCellValue(selfCarbonDioxideConcentration);
                }
                Double selfOxygenConcentration = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getSelfOxygenConcentration();
                if (selfOxygenConcentration == null) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(5).setCellValue(selfOxygenConcentration);
                }
                Double temperatureAvgMT100 = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getTemperatureAvgMT100();
                if (temperatureAvgMT100 == null) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(6).setCellValue(temperatureAvgMT100);
                }
                Double temperatureAvgMT300 = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getTemperatureAvgMT300();
                if (temperatureAvgMT300 == null) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(temperatureAvgMT300);
                }
                Double carbonDioxideConcentrationMT300 = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getCarbonDioxideConcentrationMT300();
                if (carbonDioxideConcentrationMT300 == null) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(8).setCellValue(carbonDioxideConcentrationMT300);
                }
                Double thirdYqMv = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getThirdYqMv();
                if (thirdYqMv == null) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(9).setCellValue(thirdYqMv);
                }
                Date inspectionTimeOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getInspectionTimeOnWork();
                if (inspectionTimeOnWork == null) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    String inspectionTimeOnWorkStr = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(10).setCellValue(inspectionTimeOnWorkStr);
                }
                String runningStatusOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getRunningStatusOnWork();
                if (StringUtils.isEmpty(runningStatusOnWork)) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {
                    String runningStatusOnWorkStr = changeStatus(runningStatusOnWork);
                    sheet.getRow(j).getCell(11).setCellValue(runningStatusOnWorkStr);
                }
                String checkingPeopleNameOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(12).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(12).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getInspectionTimeOffWork();
                if (inspectionTimeOffWork == null) {
                    sheet.getRow(j).getCell(13).setCellValue("");
                } else {
                    String inspectionTimeOffWorkStr = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(13).setCellValue(inspectionTimeOffWorkStr);
                }
                String runningStatusOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getRunningStatusOffWork();
                if (StringUtils.isEmpty(runningStatusOffWork)) {
                    sheet.getRow(j).getCell(14).setCellValue("");
                } else {
                    String runningStatusOffWorkStr = changeStatus(runningStatusOffWork);
                    sheet.getRow(j).getCell(14).setCellValue(runningStatusOffWorkStr);
                }
                String checkingPeopleNameOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(15).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(15).setCellValue(checkingPeopleNameOffWork);
                }
                String maintenanceRecord = list.get((int) (Math.floor((j - 3) / 4))).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(16).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(16).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get((int) (Math.floor((j - 3) / 4))).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(17).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(17).setCellValue(selfCheck);
                }
                String checker = list.get((int) (Math.floor((j - 3) / 4))).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(18).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(18).setCellValue(checker);
                }
            }
            for (int j = 0; j < list.size(); j++) {
                CellRangeAddress region10 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 16, 16);
                sheet.addMergedRegion(region10);
                CellRangeAddress region11 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 17, 17);
                sheet.addMergedRegion(region11);
                CellRangeAddress region12 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 18, 18);
                sheet.addMergedRegion(region12);
            }
        }
        try {
            String fileName = "培养箱质控记录查询导出";
            ExcelUtils.closeResponse(response, fileName, hssfWorkbook);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 环境excel导出
     */
    public void excelHJForMonth(HttpServletResponse response, int eqId, String startTime, String endTime) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取数据
        List<QualityControlReportList> list = qcEquipmentRecordService.getQualityControlReportEveryMonthForHJ(eqId, startTime, endTime);
        String nameForPYX = qcEquipmentMapper.selectDeviceNameById(eqId);
        HSSFWorkbook hssfWorkbook = ExcelUtils.setHeaders(3, 20, "环境", nameForPYX);
        HSSFSheet sheet = hssfWorkbook.getSheet("环境每月质控");
        HSSFCellStyle style = ExcelUtils.getStyle(hssfWorkbook);
        HSSFRow row = null;
        HSSFCell cell = null;
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size * 4; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 20; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(72));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            int count;
            int temp = 0;
            for (int j = 3; j < size * 4 + 3; j++) {
                if (j - 3 <= 3) {
                    count = j - 3;
                } else if ((j - 3) % 4 == 0) {
                    count = 0;
                    temp = j;
                } else {
                    count = j - temp;
                }
                sheet.getRow(j).getCell(0).setCellValue(list.get((int) (Math.floor((j - 3) / 4))).getDate());
                String time = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getTime();
                if (StringUtils.isEmpty(time)) {
                    sheet.getRow(j).getCell(1).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(1).setCellValue(time);
                }
                String environmentTemperature = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentTemperature();
                if (StringUtils.isEmpty(environmentTemperature)) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(2).setCellValue(environmentTemperature);
                }
                String environmentHumidity = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentHumidity();
                if (StringUtils.isEmpty(environmentHumidity)) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(3).setCellValue(environmentHumidity);
                }
                String environmentVOC = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentVOC();
                if (StringUtils.isEmpty(environmentVOC)) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(4).setCellValue(environmentVOC);
                }
                String environmentPM2 = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentPM2();
                if (StringUtils.isEmpty(environmentPM2)) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(5).setCellValue(environmentPM2);
                }
                String environmentPM10 = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentPM10();
                if (StringUtils.isEmpty(environmentPM10)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(6).setCellValue(environmentPM10);
                }
                String environmentOxygenConcentration = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentOxygenConcentration();
                if (StringUtils.isEmpty(environmentOxygenConcentration)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(environmentOxygenConcentration);
                }
                String environmentCarbonDioxideConcentration = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentCarbonDioxideConcentration();
                if (StringUtils.isEmpty(environmentCarbonDioxideConcentration)) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(8).setCellValue(environmentCarbonDioxideConcentration);
                }
                String environmentMethanal = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentMethanal();
                if (StringUtils.isEmpty(environmentMethanal)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(9).setCellValue(environmentMethanal);
                }
                String environmentPressure = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getEnvironmentPressure();
                if (StringUtils.isEmpty(environmentPressure)) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(10).setCellValue(environmentPressure);
                }
                Date inspectionTimeOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getInspectionTimeOnWork();
                if (inspectionTimeOnWork == null) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {
                    String timeOnWork = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(11).setCellValue(timeOnWork);
                }
                String runningStatusOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getRunningStatusOnWork();
                if (StringUtils.isEmpty(runningStatusOnWork)) {
                    sheet.getRow(j).getCell(12).setCellValue("");
                } else {
                    String runningStatusOnWorkStr = changeStatus(runningStatusOnWork);
                    sheet.getRow(j).getCell(12).setCellValue(runningStatusOnWorkStr);
                }
                String checkingPeopleNameOnWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(13).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(13).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getInspectionTimeOffWork();
                if (inspectionTimeOffWork == null) {
                    sheet.getRow(j).getCell(14).setCellValue("");
                } else {
                    String timeOffWork = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(14).setCellValue(timeOffWork);
                }
                String runningStatusOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getRunningStatusOffWork();
                if (StringUtils.isEmpty(runningStatusOffWork)) {
                    sheet.getRow(j).getCell(15).setCellValue("");
                } else {
                    String runningStatusOffWorkStr = changeStatus(runningStatusOffWork);
                    sheet.getRow(j).getCell(15).setCellValue(runningStatusOffWorkStr);
                }
                String checkingPeopleNameOffWork = list.get((int) (Math.floor((j - 3) / 4))).getQcrs().get(count).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(16).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(16).setCellValue(checkingPeopleNameOffWork);
                }
                String maintenanceRecord = list.get((int) (Math.floor((j - 3) / 4))).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(17).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(17).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get((int) (Math.floor((j - 3) / 4))).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(18).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(18).setCellValue(selfCheck);
                }
                String checker = list.get((int) (Math.floor((j - 3) / 4))).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(19).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(19).setCellValue(checker);
                }
            }
            for (int j = 0; j < list.size(); j++) {
                CellRangeAddress region10 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 17, 17);
                sheet.addMergedRegion(region10);
                CellRangeAddress region11 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 18, 18);
                sheet.addMergedRegion(region11);
                CellRangeAddress region12 = new CellRangeAddress(j * 4 + 3, j * 4 + 6, 19, 19);
                sheet.addMergedRegion(region12);
            }
        }
        try {
            String fileName = "环境质控记录查询导出";
            ExcelUtils.closeResponse(response, fileName, hssfWorkbook);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 工作台excel导出
     */
    public void excelGZTForMonth(HttpServletResponse response, int eqId, String startTime, String endTime) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取数据
        List<WorkbenchModel> workbenchModel = qcEquipmentRecordService.getWorkbenchModelEveryMonthForGZT(eqId, startTime, endTime);
        String nameForPYX = qcEquipmentMapper.selectDeviceNameById(eqId);
        HSSFWorkbook hssfWorkbook = ExcelUtils.setHeaders(3, 24, "工作台", nameForPYX);
        HSSFSheet sheet = hssfWorkbook.getSheet("工作台每月质控");
        HSSFCellStyle style = ExcelUtils.getStyle(hssfWorkbook);
        HSSFRow row = null;
        HSSFCell cell = null;
        if (CollectionUtils.isNotEmpty(workbenchModel)) {
            int size = workbenchModel.size();
            for (int k = 0; k < size; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 24; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(80));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            for (int j = 3; j < size + 3; j++) {
                sheet.getRow(j).getCell(0).setCellValue(workbenchModel.get(j - 3).getDay());
                String time = workbenchModel.get(j - 3).getBeginPollingTime();
                if (StringUtils.isEmpty(time)) {
                    sheet.getRow(j - 3).getCell(1).setCellValue("");
                } else {

                    sheet.getRow(j).getCell(1).setCellValue(time);
                }
                String begintype = workbenchModel.get(j - 3).getWorkbenchOperationTypeBegin();
                if (StringUtils.isEmpty(begintype)) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(2).setCellValue(begintype);
                }
                String oilMassBegin = workbenchModel.get(j - 3).getOilMassBegin();
                if (StringUtils.isEmpty(oilMassBegin)) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    String oilMassBegin2 = changeStatus4(oilMassBegin);
                    sheet.getRow(j).getCell(3).setCellValue(oilMassBegin2);
                }
                String motionArmBegin = workbenchModel.get(j - 3).getMotionArmBegin();
                if (StringUtils.isEmpty(motionArmBegin)) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    String motionArmBegin2 = changeStatus2(motionArmBegin);
                    sheet.getRow(j).getCell(4).setCellValue(motionArmBegin2);
                }
                String wenBoardBegin = workbenchModel.get(j - 3).getWenBoardBegin();
                if (StringUtils.isEmpty(wenBoardBegin)) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    String wenBoardBegin2 = changeStatus2(wenBoardBegin);


                    sheet.getRow(j).getCell(5).setCellValue(wenBoardBegin2);
                }
                String mineralOilBegin = workbenchModel.get(j - 3).getMineralOilBegin();
                if (StringUtils.isEmpty(mineralOilBegin)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    String mineroilBegin2 = changeStatus3(mineralOilBegin);
                    sheet.getRow(j).getCell(6).setCellValue(mineroilBegin2);
                }
                String lightSourceBegin = workbenchModel.get(j - 3).getLightSourceBegin();
                if (StringUtils.isEmpty(lightSourceBegin)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    String lightSourceBegin2 = changeStatus2(lightSourceBegin);
                    sheet.getRow(j).getCell(7).setCellValue(lightSourceBegin2);
                }
                String laserLightSourceBegin = workbenchModel.get(j - 3).getLaserLightSourceBegin();
                if (StringUtils.isEmpty(laserLightSourceBegin)) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    String laserLightSourceBegin2 = changeStatus2(laserLightSourceBegin);
                    sheet.getRow(j).getCell(8).setCellValue(laserLightSourceBegin2);
                }
                String laserFocusPositionBegin = workbenchModel.get(j - 3).getLaserFocusPositionBegin();
                if (StringUtils.isEmpty(laserFocusPositionBegin)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    String laserFocusPositionBegin2 = changeStatus2(laserFocusPositionBegin);
                    sheet.getRow(j).getCell(9).setCellValue(laserFocusPositionBegin2);
                }
                String checkingPeopleNameBegin = workbenchModel.get(j - 3).getCheckingPeopleNameBegin();
                if (StringUtils.isEmpty(checkingPeopleNameBegin)) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(10).setCellValue(checkingPeopleNameBegin);
                }
                String endtime = workbenchModel.get(j - 3).getEndPollingTime();
                if (StringUtils.isEmpty(endtime)) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {

                    sheet.getRow(j).getCell(11).setCellValue(endtime);
                }
                String endtype = workbenchModel.get(j - 3).getWorkbenchOperationTypeBegin();
                if (StringUtils.isEmpty(endtype)) {

                    sheet.getRow(j).getCell(12).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(12).setCellValue(endtype);
                }
                String oilMassEnd = workbenchModel.get(j - 3).getOilMassEnd();
                if (StringUtils.isEmpty(oilMassEnd)) {
                    sheet.getRow(j).getCell(13).setCellValue("");
                } else {
                    String oilMassEnd2 = changeStatus4(oilMassEnd);
                    sheet.getRow(j).getCell(13).setCellValue(oilMassEnd2);
                }
                String motionArmEnd = workbenchModel.get(j - 3).getMotionArmEnd();
                if (StringUtils.isEmpty(motionArmEnd)) {
                    sheet.getRow(j).getCell(14).setCellValue("");
                } else {
                    String motionArmEnd2 = changeStatus2(motionArmEnd);
                    sheet.getRow(j).getCell(14).setCellValue(motionArmEnd2);
                }
                String wenBoardEnd = workbenchModel.get(j - 3).getWenBoardEnd();
                if (StringUtils.isEmpty(wenBoardEnd)) {
                    sheet.getRow(j).getCell(15).setCellValue("");
                } else {
                    String wenBoardEnd2 = changeStatus2(wenBoardEnd);
                    sheet.getRow(j).getCell(15).setCellValue(wenBoardEnd2);
                }
                String mineralOilEnd = workbenchModel.get(j - 3).getMineralOilEnd();
                if (StringUtils.isEmpty(mineralOilEnd)) {
                    sheet.getRow(j).getCell(16).setCellValue("");
                } else {
                    String mineralOilEnd2 = changeStatus3(mineralOilEnd);
                    sheet.getRow(j).getCell(16).setCellValue(mineralOilEnd2);
                }
                String lightSourceEnd = workbenchModel.get(j - 3).getLightSourceEnd();
                if (StringUtils.isEmpty(lightSourceEnd)) {
                    sheet.getRow(j).getCell(17).setCellValue("");
                } else {
                    String lightSourceEnd2 = changeStatus2(lightSourceEnd);
                    sheet.getRow(j).getCell(17).setCellValue(lightSourceEnd2);
                }

                String laserLightSourceEnd = workbenchModel.get(j - 3).getLaserLightSourceEnd();

                if (StringUtils.isEmpty(laserLightSourceEnd)) {
                    sheet.getRow(j).getCell(18).setCellValue("");
                } else {
                    String laserLightSourceEnd2 = changeStatus2(laserLightSourceEnd);

                    sheet.getRow(j).getCell(18).setCellValue(laserLightSourceEnd2);
                }

                String laserFocusPositionEnd = workbenchModel.get(j - 3).getLaserFocusPositionEnd();
                if (StringUtils.isEmpty(laserFocusPositionEnd)) {

                    sheet.getRow(j).getCell(19).setCellValue("");
                } else {
                    String laserFocusPositionEnd2 = changeStatus2(laserFocusPositionEnd);
                    sheet.getRow(j).getCell(19).setCellValue(laserFocusPositionEnd2);
                }
                String checkingPeopleNameEnd = workbenchModel.get(j - 3).getCheckingPeopleNameEnd();
                if (StringUtils.isEmpty(checkingPeopleNameEnd)) {
                    sheet.getRow(j).getCell(20).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(20).setCellValue(checkingPeopleNameEnd);
                }
                String maintenanceRecord = workbenchModel.get(j - 3).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(21).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(21).setCellValue(maintenanceRecord);
                }
                String selfCheck = workbenchModel.get(j - 3).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(22).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(22).setCellValue(selfCheck);
                }
                String checker = workbenchModel.get(j - 3).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(23).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(23).setCellValue(checker);
                }
            }
        }
        try {
            String fileName = "工作台质控记录查询导出";
            ExcelUtils.closeResponse(response, fileName, hssfWorkbook);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    /**
     * 显微镜excel导出
     */
    public void excelXWJForMonth(HttpServletResponse response, int eqId, String startTime, String endTime) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取数据
        List<QualityControlReportList> list = qcEquipmentRecordService.getQualityControlReportEveryMonthForXWJ(eqId, startTime, endTime);
        String nameForPYX = qcEquipmentMapper.selectDeviceNameById(eqId);
        HSSFWorkbook hssfWorkbook = ExcelUtils.setHeaders(3, 12, "显微镜", nameForPYX);
        HSSFSheet sheet = hssfWorkbook.getSheet("显微镜每月质控");
        HSSFCellStyle style = ExcelUtils.getStyle(hssfWorkbook);
        HSSFRow row = null;
        HSSFCell cell = null;
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 12; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(120));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            for (int j = 3; j < list.size() + 3; j++) {
                sheet.getRow(j).getCell(0).setCellValue(list.get(j - 3).getDate());
                Date inspectionTimeOnWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOnWork();
                if (inspectionTimeOnWork == null) {
                    sheet.getRow(j).getCell(1).setCellValue("");
                } else {
                    String timeOnWork = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(1).setCellValue(timeOnWork);
                }
                String runningStatusOnWork = list.get(j - 3).getQcrs().get(0).getRunningStatusOnWork();
                if (StringUtils.isEmpty(runningStatusOnWork)) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    String runningStatusOnWorkStr = changeStatus(runningStatusOnWork);
                    sheet.getRow(j).getCell(2).setCellValue(runningStatusOnWorkStr);
                }
                String remarkOnWork = list.get(j - 3).getQcrs().get(0).getRemarkOnWork();
                if (StringUtils.isEmpty(remarkOnWork)) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(3).setCellValue(remarkOnWork);
                }
                String checkingPeopleNameOnWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(4).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOffWork();
                if (inspectionTimeOffWork == null) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    String timeOffWork = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(5).setCellValue(timeOffWork);
                }
                String runningStatusOffWork = list.get(j - 3).getQcrs().get(0).getRunningStatusOffWork();
                if (StringUtils.isEmpty(runningStatusOffWork)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    String runningStatusOffWorkStr = changeStatus(runningStatusOffWork);
                    sheet.getRow(j).getCell(6).setCellValue(runningStatusOffWorkStr);
                }
                String remarkOffWork = list.get(j - 3).getQcrs().get(0).getRemarkOffWork();
                if (StringUtils.isEmpty(remarkOffWork)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(remarkOffWork);
                }
                String checkingPeopleNameOffWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(8).setCellValue(checkingPeopleNameOffWork);
                }
                String maintenanceRecord = list.get(j - 3).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(9).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get(j - 3).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(10).setCellValue(selfCheck);
                }
                String checker = list.get(j - 3).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(11).setCellValue(checker);
                }
            }
        }
        try {
            String fileName = "显微镜质控记录查询导出";
            ExcelUtils.closeResponse(response, fileName, hssfWorkbook);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 工作站和离心机excel导出
     */
    public void excelGZZOrLXJForMonth(HttpServletResponse response, int eqId, String startTime, String endTime, String classifyId) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        HSSFWorkbook hssfWorkbook = null;
        HSSFSheet sheet = null;
        List<QualityControlReportList> list = qcEquipmentRecordService.getQualityControlReportEveryMonthForLXJOrGZZ(eqId, startTime, endTime);
        //工作站
        if (StringUtils.equals("5", classifyId)) {
            String nameForPYX = qcEquipmentMapper.selectDeviceNameById(eqId);
            hssfWorkbook = ExcelUtils.setHeaders(3, 10, "工作站", nameForPYX);
            sheet = hssfWorkbook.getSheet("工作站每月质控");
            //离心机
        } else if (StringUtils.equals("11", classifyId)) {
            String nameForPYX = qcEquipmentMapper.selectDeviceNameById(eqId);
            hssfWorkbook = ExcelUtils.setHeaders(3, 10, "离心机", nameForPYX);
            sheet = hssfWorkbook.getSheet("离心机每月质控");
        }
        HSSFCellStyle style = ExcelUtils.getStyle(hssfWorkbook);
        HSSFRow row = null;
        HSSFCell cell = null;
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 10; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(145));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            for (int j = 3; j < list.size() + 3; j++) {
                sheet.getRow(j).getCell(0).setCellValue(list.get(j - 3).getDate());
                Date inspectionTimeOnWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOnWork();
                if (inspectionTimeOnWork == null) {
                    sheet.getRow(j).getCell(1).setCellValue("");
                } else {
                    String timeOnWork = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(1).setCellValue(timeOnWork);
                }
                String runningStatusOnWork = list.get(j - 3).getQcrs().get(0).getRunningStatusOnWork();
                if (StringUtils.isEmpty(runningStatusOnWork)) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    String runningStatusOnWorkStr;
                    if (StringUtils.equals("5",classifyId)){
                        runningStatusOnWorkStr = changeStatusByGZZ(runningStatusOnWork);
                    }else {
                        runningStatusOnWorkStr = changeStatus(runningStatusOnWork);
                    }
                    sheet.getRow(j).getCell(2).setCellValue(runningStatusOnWorkStr);
                }
                String checkingPeopleNameOnWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(3).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOffWork();
                if (inspectionTimeOffWork == null) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    String timeOffWork = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(4).setCellValue(timeOffWork);
                }
                String runningStatusOffWork = list.get(j - 3).getQcrs().get(0).getRunningStatusOffWork();
                if (StringUtils.isEmpty(runningStatusOffWork)) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    String runningStatusOffWorkStr;
                    if (StringUtils.equals("5",classifyId)){
                        runningStatusOffWorkStr = changeStatusByGZZ(runningStatusOffWork);
                    }else {
                        runningStatusOffWorkStr = changeStatus(runningStatusOffWork);
                    }
                    sheet.getRow(j).getCell(5).setCellValue(runningStatusOffWorkStr);
                }
                String checkingPeopleNameOffWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(6).setCellValue(checkingPeopleNameOffWork);
                }
                String maintenanceRecord = list.get(j - 3).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get(j - 3).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(8).setCellValue(selfCheck);
                }
                String checker = list.get(j - 3).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(9).setCellValue(checker);
                }
            }
        }
        if (StringUtils.equals("5", classifyId)) {
            try {
                String fileName = "工作站质控记录查询导出";
                ExcelUtils.closeResponse(response, fileName, hssfWorkbook);
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else if (StringUtils.equals("11", classifyId)) {
            try {
                String fileName = "离心机质控记录查询导出";
                ExcelUtils.closeResponse(response, fileName, hssfWorkbook);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }


    /**
     * 胚胎库excel导出
     */
    public void excelPTKForMonth(HttpServletResponse response, int eqId, String startTime, String endTime) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<QualityControlReportList> list = qcEquipmentRecordService.getQualityControlReportEveryMonthForPTK(eqId, startTime, endTime);
        String nameForPYX = qcEquipmentMapper.selectDeviceNameById(eqId);
        HSSFWorkbook hssfWorkbook = ExcelUtils.setHeaders(3, 19, "胚胎库", nameForPYX);
        HSSFSheet sheet = hssfWorkbook.getSheet("胚胎库每月质控");
        HSSFCellStyle style = ExcelUtils.getStyle(hssfWorkbook);
        HSSFRow row = null;
        HSSFCell cell = null;
        if (CollectionUtils.isNotEmpty(list)) {
            //填数据
            int size = list.size();
            for (int k = 0; k < size; k++) {
                row = sheet.createRow(k + 3);
                //设置每一行的高
                sheet.getRow(k + 3).setHeightInPoints(40);
                for (int m = 0; m < 19; m++) {
                    cell = row.createCell(m);
                    //设置每一列的宽度和内容垂直居中
                    sheet.setColumnWidth(m, ExcelUtils.pixel2WidthUnits(80));
                    sheet.getRow(k + 3).getCell(m).setCellStyle(style);
                }
            }
            for (int j = 3; j < list.size() + 3; j++) {
                sheet.getRow(j).getCell(0).setCellValue(list.get(j - 3).getDate());
                Date inspectionTimeOnWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOnWork();
                if (null == inspectionTimeOnWork) {
                    sheet.getRow(j).getCell(1).setCellValue("");
                } else {
                    String timeOnWork = sdf.format(inspectionTimeOnWork);
                    sheet.getRow(j).getCell(1).setCellValue(timeOnWork);
                }
                String monitoringSystemOnWork = list.get(j - 3).getQcrs().get(0).getMonitoringSystemOnWork();
                if (StringUtils.isEmpty(monitoringSystemOnWork)) {
                    sheet.getRow(j).getCell(2).setCellValue("");
                } else {
                    String monitoringSystemOnWorkStr = changeStatus2(monitoringSystemOnWork);
                    sheet.getRow(j).getCell(2).setCellValue(monitoringSystemOnWorkStr);
                }
                String canisterLockOnWork = list.get(j - 3).getQcrs().get(0).getCanisterLockOnWork();
                if (StringUtils.isEmpty(canisterLockOnWork)) {
                    sheet.getRow(j).getCell(3).setCellValue("");
                } else {
                    String canisterLockOnWorkStr = changeStatus2(canisterLockOnWork);
                    sheet.getRow(j).getCell(3).setCellValue(canisterLockOnWorkStr);
                }
                String tankLockInfoOnWork = list.get(j - 3).getQcrs().get(0).getTankLockInfoOnWork();
                if (StringUtils.isEmpty(tankLockInfoOnWork)) {
                    sheet.getRow(j).getCell(4).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(4).setCellValue(tankLockInfoOnWork);
                }
                String canisterTemperatureOnWork = list.get(j - 3).getQcrs().get(0).getCanisterTemperatureOnWork();
                if (StringUtils.isEmpty(canisterTemperatureOnWork)) {
                    sheet.getRow(j).getCell(5).setCellValue("");
                } else {
                    String canisterTemperatureOnWorkStr = changeStatus2(canisterTemperatureOnWork);
                    sheet.getRow(j).getCell(5).setCellValue(canisterTemperatureOnWorkStr);
                }
                String tankTemperatureInfoOnWork = list.get(j - 3).getQcrs().get(0).getTankTemperatureInfoOnWork();
                if (StringUtils.isEmpty(tankTemperatureInfoOnWork)) {
                    sheet.getRow(j).getCell(6).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(6).setCellValue(tankTemperatureInfoOnWork);
                }
                String checkingPeopleNameOnWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOnWork();
                if (StringUtils.isEmpty(checkingPeopleNameOnWork)) {
                    sheet.getRow(j).getCell(7).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(7).setCellValue(checkingPeopleNameOnWork);
                }
                Date inspectionTimeOffWork = list.get(j - 3).getQcrs().get(0).getInspectionTimeOffWork();
                if (null == inspectionTimeOffWork) {
                    sheet.getRow(j).getCell(8).setCellValue("");
                } else {
                    String timeOffWork = sdf.format(inspectionTimeOffWork);
                    sheet.getRow(j).getCell(8).setCellValue(timeOffWork);
                }
                String monitoringSystemOffWork = list.get(j - 3).getQcrs().get(0).getMonitoringSystemOffWork();
                if (StringUtils.isEmpty(monitoringSystemOffWork)) {
                    sheet.getRow(j).getCell(9).setCellValue("");
                } else {
                    String monitoringSystemOffWorkStr = changeStatus2(monitoringSystemOffWork);
                    sheet.getRow(j).getCell(9).setCellValue(monitoringSystemOffWorkStr);
                }
                String canisterLockOffWork = list.get(j - 3).getQcrs().get(0).getCanisterLockOffWork();
                if (StringUtils.isEmpty(canisterLockOffWork)) {
                    sheet.getRow(j).getCell(10).setCellValue("");
                } else {
                    String canisterLockOffWorkStr = changeStatus2(canisterLockOffWork);
                    sheet.getRow(j).getCell(10).setCellValue(canisterLockOffWorkStr);
                }
                String tankLockInfoOffWork = list.get(j - 3).getQcrs().get(0).getTankLockInfoOffWork();
                if (StringUtils.isEmpty(tankLockInfoOffWork)) {
                    sheet.getRow(j).getCell(11).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(11).setCellValue(tankLockInfoOffWork);
                }
                String canisterTemperatureOffWork = list.get(j - 3).getQcrs().get(0).getCanisterTemperatureOffWork();
                if (StringUtils.isEmpty(canisterTemperatureOffWork)) {
                    sheet.getRow(j).getCell(12).setCellValue("");
                } else {
                    String canisterTemperatureOffWorkStr = changeStatus2(canisterTemperatureOffWork);
                    sheet.getRow(j).getCell(12).setCellValue(canisterTemperatureOffWorkStr);
                }
                String tankTemperatureInfoOffWork = list.get(j - 3).getQcrs().get(0).getTankTemperatureInfoOffWork();
                if (StringUtils.isEmpty(tankTemperatureInfoOffWork)) {
                    sheet.getRow(j).getCell(13).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(13).setCellValue(tankTemperatureInfoOffWork);
                }
                String checkingPeopleNameOffWork = list.get(j - 3).getQcrs().get(0).getCheckingPeopleNameOffWork();
                if (StringUtils.isEmpty(checkingPeopleNameOffWork)) {
                    sheet.getRow(j).getCell(14).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(14).setCellValue(checkingPeopleNameOffWork);
                }
                String isAddLiquidNitrogen = list.get(j - 3).getIsAddLiquidNitrogen();
                if (StringUtils.isEmpty(isAddLiquidNitrogen)) {
                    sheet.getRow(j).getCell(15).setCellValue("否");
                } else {
                    if (StringUtils.equals("0", isAddLiquidNitrogen)) {
                        sheet.getRow(j).getCell(15).setCellValue("否");
                    } else if (StringUtils.equals("1", isAddLiquidNitrogen)) {
                        sheet.getRow(j).getCell(15).setCellValue("是");
                    }
                }
                String maintenanceRecord = list.get(j - 3).getMaintenanceRecord();
                if (StringUtils.isEmpty(maintenanceRecord)) {
                    sheet.getRow(j).getCell(16).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(16).setCellValue(maintenanceRecord);
                }
                String selfCheck = list.get(j - 3).getSelfCheck();
                if (StringUtils.isEmpty(selfCheck)) {
                    sheet.getRow(j).getCell(17).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(17).setCellValue(selfCheck);
                }
                String checker = list.get(j - 3).getChecker();
                if (StringUtils.isEmpty(checker)) {
                    sheet.getRow(j).getCell(18).setCellValue("");
                } else {
                    sheet.getRow(j).getCell(18).setCellValue(checker);
                }
            }
        }
        try {
            String fileName = "胚胎库质控记录查询导出";
            ExcelUtils.closeResponse(response, fileName, hssfWorkbook);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 根据设备类型导出当前设备类型下所有设备的月excel表格
     *
     * @param response
     * @param classifyId
     * @param startTime
     * @param endTime
     */
    @Override
    public void excelByClassifyAllForMonth(HttpServletResponse response, String classifyId, String startTime, String endTime) {
        List<QcEquipment> qcEquipments = qcEquipmentMapper.selectList(Wrappers.lambdaQuery(new QcEquipment())
                .eq(QcEquipment::getClassifyId, classifyId));
        if (CollectionUtils.isNotEmpty(qcEquipments)) {
            List<Integer> eqIds = qcEquipments.stream()
                    .map(QcEquipment::getId).collect(Collectors.toList());
            if (StringUtils.equals("1", classifyId) || StringUtils.equals("2", classifyId) ||
                    StringUtils.equals("4", classifyId) || StringUtils.equals("5", classifyId)
                    || StringUtils.equals("6", classifyId) || StringUtils.equals("7", classifyId)
                    || StringUtils.equals("9", classifyId) || StringUtils.equals("11", classifyId)) {
                this.excelForMonthAll(response, eqIds, startTime, endTime, classifyId);
            } else {
                throw new RuntimeException("传入设备类型id值有误");
            }
        }
    }

    @Override
    public void exportExcel(HttpServletResponse response, QcRecordStatusModel qcRecordStatusModel) {
        List<QcEquipmentRecordModel> qcEquipmentRecordModels = qcEquipmentRecordService.findEqDeatil(qcRecordStatusModel);
        Map<String, List<QcEquipmentRecordModel>> collect = qcEquipmentRecordModels.stream().collect(Collectors.groupingBy(QcEquipmentRecordModel::getClassifyId));
        Set<String> classiFyIds = collect.keySet();
        HSSFWorkbook workbook = new HSSFWorkbook();
        classiFyIds.forEach(s -> {
            //各种类型设备excel适配器
            List<QcEquipmentRecordModel> qcEquipmentRecordModels1 = collect.get(s);
            QcEqRdExcelUtil.exportExcel(workbook, s, qcEquipmentRecordModels1);
        });
        try {
            String fileName = "巡检记录查询导出";
            ExcelUtils.closeResponse(response, fileName, workbook);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
